akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = (int)1e5 + 1000;
int n, u, v, a[maxn], b[maxn], vis[maxn];
vvi g(maxn);
 
void dfs1(int now, int step) {
	for (auto it : g[now]) {
		if (a[it] == -1) {
			a[it] = step + 1;
			dfs1(it, step + 1);
		}
	}
}
void dfs2(int now, int step) {
	for (auto it : g[now]) {
		if (b[it] == -1) {
			b[it] = step + 1;
			dfs2(it, step + 1);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	ms(a, -1); ms(b, -1);
	cin >> n >> u >> v;
	forn(i, n - 1) {
		int e1, e2;
		cin >> e1 >> e2;
		g[e1].pb(e2);
		g[e2].pb(e1);
	}
	a[u] = 0;
	dfs1(u, 0);
	b[v] = 0;
	dfs2(v, 0);
	int ans = -1;
//	for1(i, n) cerr << a[i] << " " << b[i] << endl;
	for1(i, n) {
		if (a[i] <= b[i]) {
			ans = max(ans, b[i]);
		}
	}
	cout << (ans - 1) << '\n';
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 9088
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define pb push_back
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rii(x,y) ri(x), ri(y)
#define rll(x,y) rl(x), rl(y)

#define fst first
#define snd second
#define dprintf debug && printf
#define debug false

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

int N;
ll A, B, C, D;

bool check(ll top, ll bot, ll m){
	if(top + D*m >= B && B >= bot + C*m) return true;
	if(top - C*m >= B && B >= bot - D*m) return true;
	return false;
}

int main(){
	ri(N); rll(A,B); rll(C,D); N-=1;
	bool good=false;
	ll top=A, bot=A; int n=0;
	while(n<N){
		int m=N-n;
		good|=check(top,bot,m);
		n++;
		top += D;
		bot += C;
	}
	top=A; bot=A; n=0;
	while(n<N){
		int m=N-n;
		good|=check(top,bot,m);
		n++;
		top -= C;
		bot -= D;
	}
	printf(good?"YES\n":"NO\n");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int a, b;
   cin >> a >> b;
   
   if (a == b)
       cout << "a == b" << endl; 
   else if (a > b)
       cout << "a > b" << endl;
   else
       cout << "a < b" << endl;
   
   return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=998244353;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=1e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e6+10,M=3e2+10;
	//------------------FIXED------------------
	
	void main()
	{
		map<int,int> ct;int n=qread();fo(i,1,n) ct[qread()]++;
		int ans=0;for(auto in:ct) ans+=(in.SE>=in.FR?in.SE-in.FR:in.SE),debug("%d\n",ans);write(ans);
	}
};//����������
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 28160
N = int(input())
book = []
for i in range(N):
    city, sco = input().split()
    sco = int(sco)
    book.append({'city':city, 'score':sco, 'number':i+1})

book.sort(key = lambda x: (x['city'],-x['score']))

for j in range(N):
    print(book[j]['number'])


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

int main(){
  double maxh = -1, minh = 999999999;
  double h;

  while(cin >> h){
    maxh = max(maxh, h);
    minh = min(minh, h);
  }

  printf("%.10f\n", maxh - minh);
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<ctime>
#include<cstdlib>
#include<vector>
using namespace std;
int n,m;
char s[1001][1001],shuchu[1001][1001];
char c(int i,int j)
{
	int ans=0;
	if(s[i][j]=='#')return '#';
	
	if(i-1>=1&&j-1>=1){
		if(s[i-1][j-1]=='#')ans++;
	}
	if(i-1>=1&&j>=1)
	{
		if(s[i-1][j]=='#')ans++;
	}
	if(i-1>=1&&j+1<=m)
	{
		if(s[i-1][j+1]=='#')ans++;
	}
	if(i>=1&&j-1>=1){
		if(s[i][j-1]=='#')ans++;
	}
	if(i>=1&&j+1<=m){
		if(s[i][j+1]=='#')ans++;
	}
	if(i+1<=n&&j-1>=1){
		if(s[i+1][j-1]=='#')ans++;
	}
	if(i+1<=n&&j>=1){
		if(s[i+1][j]=='#')ans++;
	}
	if(i+1<=n&&j+1<=m){
		if(s[i+1][j+1]=='#')ans++;
	}
	return (char)(ans+(int)'0');
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>s[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		shuchu[i][j]=c(i,j);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		cout<<shuchu[i][j];
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
using namespace std;
int happiness(int n)
{
	int out=0;
	while(n>0)
	{
		while(n>=500){
			out+=1000;
			n-=500;
		}
		return out+(n/5)*5;
	}
	return 0;
}
int main()
{
	int n;
	cin>>n;
	cout<<happiness(n);
}

Measured memory_bytes: 256
#include<iostream>
#define MAX 1000000
using namespace std;
int ans1[MAX+10],ans2[MAX+10],box[300];
void tab_make(){
	for(int i=1;;i++){
		box[i]=(i*(i+1)*(i+2)/6);
	if(i*(i+1)*(i+2)/6>MAX)
		break;
	}
}
void ans_make(){
	ans1[0]=ans2[0]=0;
	for(int i=1;i<=MAX;i++){
		ans1[i]=ans2[i]=i;
		for(int j=1;i-box[j]>=0;j++){
			ans1[i]=min(ans1[i],ans1[i-box[j]]+1);
			if(box[j]%2==1)
			ans2[i]=min(ans2[i],ans2[i-box[j]]+1);
		}
	}
}
int main(){
	int x;
	tab_make();
	ans_make();
	while(cin>>x,x){
		cout<<ans1[x]<<' '<<ans2[x]<<endl;
	}
	return 0;
}

Measured memory_bytes: 8516
from collections import Counter
N=int(input())
S=input()
C=Counter(S)
nr=C["R"]
ng=C["G"]
nb=C["B"]
ans=nr*ng*nb
for i in range(N-2):
    for j in range(i+1,N-1):
        k=j+j-i
        if k<N:
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                ans-=1

print(ans)

Measured memory_bytes: 73988
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] c = sc.next().toCharArray();
		long k = sc.nextLong();
		boolean b = true;
		int i = 0;
		for (; i < c.length; i++) {
			if (c[i] != '1') {
				b = false;
				break;
			}
		}
		if (b) {
			System.out.println(1);
		} else {
			if (k < i + 1) {
				System.out.println(1);
			} else {
				System.out.println(c[i]);
			}
		}
	}
}


Measured memory_bytes: 22612
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(n);
    VIN(ll, v, n);
    ll res = 0;
    rep(i, n) {
        reps(j, i+1, n) {
            reps(k, j+1, n) {
                if (v[i]+v[j]>v[k] && v[j]+v[k]>v[i] && v[k]+v[i]>v[j] &&
                    v[i] != v[j] && v[j] != v[k] && v[k] != v[i])
                    ++res;
            }
        }
    }
    cout << res << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vector<ii> > vvii;
typedef long long ll;

string r = "";
string x;

int solve(int pos, int sum){
	if(pos == 0){
		return (sum == 7);
	}
	if(solve(pos - 1, sum + (x[pos] - '0'))){
		r += "+";
		r += x[pos];
		return 1;
	} else if(solve(pos - 1, sum - (x[pos] - '0'))){
		r += "-";
		r += x[pos];
		return 1;
	}
	return 0;
}

int main(){
    cin >> x;
    r += x[0];
    solve(x.size() - 1, x[0] - '0');
    r += "=7";
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
s=[input() for _ in [0]*h]
l=[]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':l.extend([[i,j]])
a=''
for i in range(h):
    for j in range(w):
        if [i,j] in l:a+='#'
        else:
            c=0
            for m in l:
                if abs(i+j-sum(m))+abs(i-j-m[0]+m[1])==2:c+=1
            a+=str(c)
for i in range(h):print(a[w*i:w*(i+1)])

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll X, N ;
    map<ll,ll> bad;
    cin >> X >> N ;
    rep(i, N){
        ll inp; cin >> inp;
        bad[inp] = true;
    }
    
    for(int i = 0; i <= 101; i++){
        for(int j = -1; j <= 1;j += 2){
            int aim = X + (i * j);
            if(!bad[aim]){
                cout << aim << endl;
                return 0;
            }
        }
    }

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  ull s, c; cin >> s >> c;
  ull ans = 0;
  if(2*s <= c) {
    ans += s;
    c -= 2*s; s = 0;
  } else {
    ans += c/2;
    c = c%2; s = 0;
  }
  ans += c/4;
  cout << ans << endl;
}


Measured memory_bytes: 256
a, b, c, k = map(int, input().split())
ans = 0

if a <= k:
    ans += a
    k -= a

elif a > k:
    ans += k
    k -= k

if k > 0:
    if b <= k:
        k -= b
    else:
        k -= k

if k > 0:
    if c <= k:
        ans -= c
    else:
        ans -= k

print(ans)
    

Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<string>
#include<string.h>
#include<fstream>
#include<algorithm>
#include<set>
using namespace std;

int n;

int main()
{
	
	std::ofstream ofs( "ans.txt" );


	while(cin>>n && n!=0){
		set<string> S;
		vector<string> in;
		for(int i=0;i<n;i++){
			string t;cin>>t;
			if(S.count(t)) continue;
			S.insert(t);
			in.push_back(t);
		}
		n=in.size();

		vector<string> s;
		for(int i=0;i<n;i++){
			bool lap=false;
			for(int j=0;j<n;j++){
				if(i==j) continue;
				if(in[i].size()>in[j].size()) continue;
				for(int k=0;k<=in[j].size()-in[i].size();k++){
					if(in[j].substr(k,in[i].size())==in[i])
						lap=true;
				}
			}
			if(!lap) s.push_back(in[i]);
		}
		n=s.size();
		string p[10][10];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				p[i][j]=s[j];
				for(int k=0;k<min(s[i].size(),s[j].size());k++){
					if(s[i].substr(s[i].size()-1-k)==s[j].substr(0,k+1)){
						p[i][j]=s[j].substr(k+1);
					}
				}
			}
		}
		int cost[10][1<<10];
		string ans[10][1<<10];
		for(int i=0;i<n;i++){
			for(int b=0;b<(1<<n);b++){
				cost[i][b]=10000000;
				ans[i][b]="";
			}
			cost[i][1<<i]=s[i].size();
			ans[i][1<<i]=s[i];
		}

		for(int bit=1;bit<(1<<n);bit++){
			for(int i=0;i<n;i++){
				if(!(bit & (1<<i))) continue;
				for(int j=0;j<n;j++){
					if(bit & (1<<j)) continue;
					int next_bit=(bit | (1<<j));
					int next_c=cost[i][bit]+p[i][j].size();
					string next_s=ans[i][bit]+p[i][j];
					if(cost[j][next_bit]>next_c){
						cost[j][next_bit]=next_c;
						ans[j][next_bit]=next_s;
					}
					else if(cost[j][next_bit]==next_c){
						ans[j][next_bit]=min(ans[j][next_bit],next_s);
					}
				}
			}
		}
		int mini_cost=1000000;
		string f_ans="";
		for(int i=0;i<n;i++){
			if(mini_cost>ans[i][(1<<n)-1].size()){
				mini_cost=ans[i][(1<<n)-1].size();
				f_ans=ans[i][(1<<n)-1];
			}
			else if(mini_cost==ans[i][(1<<n)-1].size()){
				f_ans=min(f_ans,ans[i][(1<<n)-1]);
			}
		}
		cout<<f_ans<<endl;
		ofs<<f_ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1372
from collections import defaultdict

n = int(input())
v = list(map(int, input().split(' ')))

odd = defaultdict(int)
even = defaultdict(int)
al = defaultdict(int)

for i in range(len(v)):
  al[v[i]] += 1
  if(i % 2 == 0): # even
    even[v[i]] += 1
  else: # odd
    odd[v[i]] += 1

if(len(al) == 1):
  print(n // 2)
  exit()

even_sorted = sorted(even.items(), key=lambda x: x[1], reverse=True)
odd_sorted = sorted(odd.items(), key=lambda x: x[1], reverse=True)

#print(even_sorted[0:4])
#print(odd_sorted[0:4])


if(len(even_sorted) == 1): # what if either of them had only one uniq num..
  if(odd_sorted[0][0] == even_sorted[0][0]):
    print(n - odd_sorted[1][1]  - even_sorted[0][1])
  else:
    print(n - odd_sorted[0][1] - even_sorted[0][1])
elif(len(odd_sorted) == 1):
  if(odd_sorted[0][0] == even_sorted[0][0]):
    print(n - even_sorted[1][1] - odd_sorted[0][1])
  else:
    print(n - odd_sorted[0][1] - even_sorted[0][1])


else: # both of them have more than 1 uniq num..
  if(odd_sorted[0][0] == even_sorted[0][0]):
    if(odd_sorted[0][1] == even_sorted[0][1]):
      if(odd_sorted[1][1] < even_sorted[1][1]):
        print(n - odd_sorted[0][1] - even_sorted[1][1])
      else:
        print(n - odd_sorted[1][1] - even_sorted[0][1])
    elif(odd_sorted[0][1] < even_sorted[0][1]): # odd to be changed (even stays)
      print(n - odd_sorted[1][1] - even_sorted[0][1])
    else:
      print(n - odd_sorted[0][1] - even_sorted[1][1])
  else: # both has more than 1 uniq num, and most freq values aren't the same
    print(n - odd_sorted[0][1] - even_sorted[0][1])



Measured memory_bytes: 27992
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize, m: usize,
        mut xyz: [[i64; 3]; n],
    }
    let mut ans = 0;

    for i in 0..8 {
        let mut sign = vec![];
        for j in 0..3 {
            if i & (1 << j) == 0 {
                sign.push(1);
            } else {
                sign.push(-1);
            }
        }
        xyz.sort_by_key(|v| sign[0] * v[0] + sign[1] * v[1] + sign[2] * v[2]);
        let mut v = vec![0; 3];
        for j in 0..m {
            for k in 0..3 {
                v[k] += xyz[j][k];
            }
        }
        ans = max(ans, v.iter().map(|v| v.abs()).sum::<i64>());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new RitProC().doIt();
	}
	class RitProC{
		int n;
		HashMap<String, Integer> map_str;
		HashMap<Integer, String> map_int;
		int[] prise;
		boolean[][] map;
		boolean[] close;
		int cnt;
		void doIt(){
			n = in.nextInt();
			prise = new int[n];
			map_str = new HashMap<String, Integer>();
			map_int = new HashMap<Integer, String>();
			map = new boolean[n][n];
			for(int i=0;i<n;i++){
				String obj = in.next();
				prise[i] = in.nextInt();
				map_str.put(obj, i);
				map_int.put(i, obj);
			}
			int m = in.nextInt();
			for(int i=0;i<m;i++){
				int index1 = map_str.get(in.next());
				int index2 = map_str.get(in.next());
				map[index1][index2] = map[index2][index1] = true;
			}
			int sum = 0;
			close = new boolean[n];
			Arrays.fill(close, true);
			for(int i=0;i<n;i++)if(close[i]){
				cnt = 0;
				int minPrise = dijkstra(i);
				sum += (minPrise * cnt);
			}
			System.out.println(sum);
		}
		
		int dijkstra(int v){
			PriorityQueue<Integer> q = new PriorityQueue<Integer>();
			q.add(v);
			int minPrise = prise[v];
			while(q.size()>0){
				int index = q.remove();
				if(close[index] == false)continue;
				cnt++;
				close[index] = false;
				minPrise = Math.min(prise[index], minPrise);
				for(int i=0;i<n;i++)if(close[i] && map[index][i])q.add(i);
			}
			return minPrise;
		}
		
	}	
	
}

Measured memory_bytes: 88388
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    string s; cin >>s;

    if (s[0] == s[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    } 

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000 + 5;
const int BIG = 2e9;

int n, m;
int x, y, u, v;
char cell[maxN][maxN];
int dist[maxN][maxN];

bool isIn(int row, int col) {
    return (1 <= row) && (row <= n) && (1 <= col) && (col <= m);
}

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

    cin >> n >> m >> x >> y >> u >> v;

    for(int i = 1; i <= n; i++)
        cin >> (cell[i] + 1);

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            dist[i][j] = BIG;

    deque<pair<int, int> > que;
    que.push_back({x, y});
    dist[x][y] = 0;

    int dRow[4] = {-1, 0, 1, 0};
    int dCol[4] = {0, -1, 0, 1};

    while(!que.empty()) {
        int currentRow = que.front().first, currentCol = que.front().second;
        que.pop_front();

        for(int i = 0; i < 4; i++) {
            int nextRow = currentRow + dRow[i];
            int nextCol = currentCol + dCol[i];

            if(isIn(nextRow, nextCol) && (cell[nextRow][nextCol] == '.'))
                if(dist[nextRow][nextCol] > dist[currentRow][currentCol]) {
                    dist[nextRow][nextCol] = dist[currentRow][currentCol];
                    que.push_front({nextRow, nextCol});
                }
        }

        for(int nextRow = currentRow - 2; nextRow <= currentRow + 2; nextRow++)
            for(int nextCol = currentCol - 2; nextCol <= currentCol + 2; nextCol++)
                if(isIn(nextRow, nextCol) && (cell[nextRow][nextCol] == '.')) {
                    if(dist[nextRow][nextCol] > dist[currentRow][currentCol] + 1) {
                        dist[nextRow][nextCol] = dist[currentRow][currentCol] + 1;
                        que.push_back({nextRow, nextCol});
                    }
                }
    }

    if(dist[u][v] >= BIG) {
        dist[u][v] = -1;
    }

    cout << dist[u][v] << '\n';

    return 0;
}


Measured memory_bytes: 8616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            string s = Line, t = Line;
            if (Enumerable.Range(0, s.Length).All(i => s[i] == t[i]))
            {
                System.Console.WriteLine("Yes");
            }
            else
            {
                System.Console.WriteLine("No");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 26688
#include "bits/stdc++.h"
using namespace std;

vector<int>as;
bool ok(int a,int b){
  return abs(as[a]-as[b])<=1;
}

int main() {
  while(1){
    
    int N;cin>>N;
    if(!N)break;
    as.resize(N);
    vector<vector<int>>dp(N+1,vector<int>(N+1,-100000));
    for(int i=0;i<N;++i){
      int a;cin>>a;as[i]=a;
    }
    for(int i=0;i<=N;++i){
      dp[i][i]=0;
    }
    for(int t=2;t<=N;++t){
      for(int l=0;l<=N-t;++l){
	const int r=l+t;
	dp[l][r]=max(dp[l+1][r],dp[l][r-1]);
	if(ok(l,l+1))dp[l][r]=max(dp[l+2][r]+2,dp[l][r]);
	if(ok(r-2,r-1))dp[l][r]=max(dp[l][r-2]+2,dp[l][r]);
	if(ok(l,r-1)){
	  if(dp[l+1][r-1]==(r-l-2)){
	    dp[l][r]=max(dp[l+1][r-1]+2,dp[l][r]);
	  }
	}
	for(int m=l+1;m<=r-1;++m){
	  dp[l][r]=max(dp[l][m]+dp[m][r],dp[l][r]);
	}
      } 
    }

    int ans=dp[0][N];
    ans=max(0,ans);
    cout<<ans<<endl;
  }
  return 0;
}

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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

const int MAX_N = 20;
const int MAX_M = 2001;

int n, A[MAX_N], q, m;

char can_mk[MAX_M];

int main() {
    REP(i, MAX_M) can_mk[i] = 0;

    cin >> n;
    REP(i, n) cin >> A[i];

    REP(bit, 1<<n) {
        int sum = 0;
        REP(i, n) {
            if (bit & 1<<i) sum += A[i];
        }
        if (sum < MAX_M) can_mk[sum] = 1;
    }

    cin >> q;
    REP(i, q) {
        cin >> m;
        if (can_mk[m]) PRINT("yes");
        else PRINT("no");
    }

    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  int n,k,d,val,ans=0;
  cin>>n>>k;
  vector<bool>snukes(n+10,false);
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>val;
      snukes[val]=true;
    }
  }
  for(int i=1;i<=n;i++){
    if(!snukes[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
long long p = 1000000007;
long long ans;
char s[60];
int f[60];
int n, x, y;
int main() {
	scanf("%d", &n);
	scanf(" %s", s);
	scanf(" %s", s);
	if (n == 1) {
		printf("3\n");
		return 0;
	}
	while (x < n - 1) {
		if (s[x] == s[x + 1]) {
			f[y] = 1;
			y++;
			x += 2;
		}
		else {
			f[y] = 0;
			y++;
			x++;
		}
	}
	if (s[n - 1] != s[n - 2]) {
		f[y] = 0;
		y++;
	}
	ans = 3;
	if (f[0])ans *= 2;
	for (int i = 1; i < y; i++) {
		if (f[i - 1] == 0) {
			ans *= 2;
			ans %= p;
		}
		if (f[i] && f[i - 1]) {
			ans *= 3;
			ans %= p;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int a, b, c; cin >> a >> b >> c;
    vector<int> ar = {a,b,c};
    sort(ar.rbegin(),ar.rend());
    cout << ar[0] * 10 + ar[1] + ar[2] << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

#define MY_DEB 0

#if MY_DEB
#define Debug(item) cout<<item<<endl;
#else
#define Debug(item) 
#endif


int N,M;
vector<ll> A_arr;
vector<ll> B_arr;


//int dfs(int i,int j, ll K){
//
//	if(memo[i][j][K] != -1)return memo[i][j][K];
//
//	if(i < N && K - A_arr[i] >= 0){
//		if(memo[i+1][j][K - A_arr[i]] != -1)memo[i+1][j][K - A_arr[i]] = dfs(i + 1,j, K - A_arr[i]) + 1;
//	}
//
//	if(j < M && K - B_arr[i] >= 0){
//		if(memo[i][j+1][K - A_arr[i]] != -1)memo[i][j+1][K - B_arr[i]] = dfs(i,j + 1, K - B_arr[i]) + 1;
//	}
//
//	return memo[i][j][K] = max(memo[i+1][j][K-A_arr[i]],memo[i][j+1][K - B_arr[i]]);
//
//}
int main(){
	
	ll K;
	cin>>N>>M>>K;
	A_arr.resize(N);
	B_arr.resize(M);
	REP(i,N)cin>>A_arr[i];
	REP(i,M)cin>>B_arr[i];
	ll best_j = 0;
	ll best_sum = 0;
	ll now_sum = 0;
	for(best_j = 0; best_j < M && B_arr[best_j] <= K; best_j++){
			K -= B_arr[best_j];
			best_sum++;
	}
	
	best_sum = max(best_j,best_sum);
	int best_i = 0;

	while(best_i < N && A_arr[best_i] <= K){
		K -= A_arr[best_i];
		best_sum++;
		best_i++;
	}
	
	now_sum = best_sum;
	Debug("now")
	Debug(now_sum)
	for(int j = best_j; j > 0; j--){

		K += B_arr[j-1];
		Debug("K : "<<K)
		now_sum = now_sum - 1;
		while(best_i < N && A_arr[best_i] <= K){
			K -= A_arr[best_i];
			Debug("A:"<<A_arr[best_i])
			best_i++;
			now_sum++;
		}
		Debug(now_sum)
		best_sum = max(now_sum,best_sum);
	}


	cout<<best_sum<<endl;	
	return 0;	
}
//	A_arr[N] = INT_MAX;
//	B_arr[M] = INT_MAX;
//	int ans = 0;
//	for(int i = 0,j = 0; (i < N) || (j < M); ){
//
//		if(A_arr[i] <= B_arr[j]){
//			if(K - A_arr[i] >= 0){
//				K -= A_arr[i];
//				Debug(A_arr[i])
//				i++;
//			}
//			else break;
//		}
//		else{
//			if( K - B_arr[j] >= 0){
//				K -= B_arr[j];
//				Debug(B_arr[j])
//				j++;
//			}
//			else break;
//		}
//		ans++;
//	}



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

signed main(){
	int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> r;
    vector<int> w;
    for(int i=0;i<n;i++){
    	if(s[i]=='W') w.push_back(i);
	}
    for(int i=n-1;i>=0;i--){
    	if(s[i]=='R') r.push_back(i);
	}
	int ans=0;
	int m=min(r.size(),w.size());
	for(int i=0;i<m;i++){
    	if(w[i]<r[i]) ans++;
	}
	cout<<ans;
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, x);
  out(8 - (x - 400) / 200);
}


Measured memory_bytes: 3532
def diffStr(a, b):
    i = 0
    diff = 0
    lenA = len(a)
    lenB = len(b) 
    while True:
        if i == lenA:
            break
        if i == lenB:
            break
        if a[i] != b[i]:
            diff += 1
        i += 1
    diff += abs(lenA - lenB)
    return diff

s = input()
n = len(s)
a = b = ''
c = False
for i in range(n):
    a += '1' if c else '0'
    b += '0' if c else '1'
    c = not c

diffA = diffStr(s, a)
diffB = diffStr(s, b)
print(min(diffA, diffB))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int n, m;
vector <int> v;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    v = vector <int> (n+1);
    for(int i = 1; i<= n; i++) v[i] = i;
    vector <int> cnt(n+1, 1);
    vector <vector<int>> cc(n+1);
    for(int i = 1; i <= n; i++) cc[i].pb(i);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        if(v[a] == v[b]) continue;
        int x = v[a];
        int y = v[b];
        if(cnt[x] > cnt[y]){
            while(cc[y].size() > 0){
                int z = cc[y].back();
                cc[y].pop_back();
                v[z] = x;
                cc[x].pb(z);
            }
            cnt[x] += cnt[y];
            cnt[y] = 0;
        }
        else{
            while(cc[x].size() > 0){
                int z = cc[x].back();
                cc[x].pop_back();
                v[z] = y;
                cc[y].pb(z);
            }
            cnt[y] += cnt[x];
            cnt[x] = 0;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans, (ll)cnt[i]);
    cout << ans << "\n";
    //for(int i = 1; i <= n; i++) cout << cnt[i] << " ";
}


Measured memory_bytes: 18724
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
int fpr(int x);
int main(){
    int x;cin>> x;
    //cout << fpr(x) << endl;
    FOR(i,x,INF){
        //cout << fpr(i) << endl;
        if(fpr(i)!=0){
            cout << i << endl;
            goto OUT;
        }
    }
   OUT: return 0;


}

int fpr(int x){
    int rootx = floor(sqrt(x));
    //cout << rootx<< endl;
    bool flag = false;
    FOR(i,2,rootx+1){
        if(x%i == 0){
            flag = true;//合成数
            break;

        }

    }
    if (flag){//合成数の時は0を返す
        return 0;
    }
    else{  
     return x;//素数の時はその数を返す
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var T = Read();
            var ans = new string('z', S.Length);

            for (int i = 0; i <= S.Length - T.Length; i++)
            {
                var tmp = "";
                for (int j = 0; j < S.Length; j++)
                {
                    if (j >= i && j < i + T.Length)
                    {
                        if (S[j] == '?')
                        {
                            tmp += T[j - i];
                        }
                        else if (S[j] == T[j - i])
                        {
                            tmp += S[j];
                        }
                        else
                        {
                            tmp = new string('z', S.Length);
                            break;
                        }
                    }
                    else
                    {
                        if (S[j] == '?') tmp += "a";
                        else tmp += S[j];
                    }
                }
                if (tmp.CompareTo(ans) == -1) ans = tmp;
            }

            Console.WriteLine(ans != new string('z', S.Length) ? ans : "UNRESTORABLE");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int dp[100010];
int h[100010];
int n;

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

    dp[0] = 0;

    for(int i = 1; i < n; ++i) {
        if(i == 1) {
            dp[1] = dp[0] + abs(h[1]-h[0]);
        }else {
            dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
        }
    }
    cout << dp[n-1] << endl;
}

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

S = raw_input()
length = len(S)

def dfs(depth, S):

    if depth == length - 1:
        return eval(S)

    # 「+」を入れない場合
    sum1 = dfs(depth + 1, S)

    # 「+」を入れる場合
    sum2 = dfs(depth + 1, insert_plus(S, depth))

    return sum1 + sum2

def insert_plus(S, depth):
    d = depth + S.count("+") + 1
    return "{0}{1}{2}".format(S[:d],"+",S[d:])

print dfs(0,S)

Measured memory_bytes: 2568
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;

ll par[N];
ll sz[N];

ll find(ll x){
  while(par[x]!=x)x=par[x];
  return x;
}

void unio(ll a,ll b){
a=find(a),b=find(b);
if(a==b)return;
if(sz[a]<sz[b])swap(a,b);
sz[a]+=sz[b];
par[b]=a;
}


int main()
{ 

IOS;


ll n,m;cin>>n>>m;

vl p(n+1);

for(int i=1;i<=n;i++){
  par[i]=i;
  sz[i]=1;
  cin>>p[i];
}

vl f[N];

while(m--){
  ll a,b;cin>>a>>b;
  unio(a,b);
}

ll ans=0;

for(int i=1;i<=n;i++){
  ll a=find(i);
  f[a].pb(i);
}




for(int i=1;i<=n;i++){
  for(auto d:f[i]){
    if(bs(all(f[i]),p[d]))++ans;
  }
}

cout<<ans<<endl;


return 0;
 
}


Measured memory_bytes: 11096
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  string S; cin >> S;
  reverse(S.begin(),S.end());
  string a = "dream";
  string b = "dreamer";
  string c = "erase";
  string d = "eraser";
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  reverse(c.begin(),c.end());
  reverse(d.begin(),d.end());
  int len = 0;
  while( len < S.length() ) {

    string tmp = S.substr(len,7);
    string tmp2 = S.substr(len,6);
    string tmp3 = S.substr(len,5);
    if ( tmp == b ) {
      len += 7;
    } else if ( tmp3 == a || tmp3 == c ) {
      len += 5;
    } else if ( tmp2 == d ) {
      len += 6;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


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

typedef long long ll;
const int MOD = 1000000007;

int main(){
  ll N,K,S;
  cin >> N >> K >> S;
  if(S == 1000000000){
    for(int i = 0; i < N; i++){
      if(i < K){
	cout << S << " ";
      }else{
	cout << S - 1 << " ";
      }
    }
    cout << endl;
  }else{
    for(int i = 0; i < N; i++){
      if(i < K){
	cout << S << " ";
      }else{
	cout << S + 1 <<  " ";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type prob struct {
	p, score, bonus, sum int
}

func main() {
	d, g := uint(getInt()), getInt()
	ps := make([]prob, d)
	for i := range ps {
		ps[i].p = getInt()
		ps[i].bonus = getInt()
		ps[i].score = (i + 1) * 100
		ps[i].sum = (ps[i].p * ps[i].score) + ps[i].bonus
	}

	ans := 1 << 60
	for i := 0; i < (1 << d); i++ {
		tmp := 0
		cnt := 0
		x := uint(0)
		for j := uint(0); j < d; j++ {
			k := 1 << j
			if (i & k) > 0 {
				tmp += ps[j].sum
				cnt += ps[j].p
			} else {
				x = j
			}
		}

		for j := 0; (tmp < g) && (j < ps[x].p-1); j++ {
			tmp += ps[x].score
			cnt++
		}

		if tmp >= g {
			ans = min(ans, cnt)
		}
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
from collections import deque
n,m=map(int,input().split())
ilist=[[] for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    ilist[a-1].append(b)
    ilist[b-1].append(a)

out=[0 for i in range(n)]

seen={1}
next=[[1],[]]
i=0
while len(next[0])+len(next[1]) != 0:
    if i == 0:
        x=1
    else:
        x=0
    
    for j in next[i]:
        for k in ilist[j-1]:
            if not k in seen:
                seen.add(k)
                next[x].append(k)
                out[k-1]=j
    next[i]=[]
    i=x

print("Yes")
for o in out[1:]:
    print(o)                    
    
    



Measured memory_bytes: 39952