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


int main() {
    int N;
    cin >> N;
    vector <string> data(N);
    for (int i =0; i<N; i++) 
        cin >> data.at(i);
    bool flag = true;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if (data.at(i) == data.at(j)) {
                flag = false;
                break;
            }
        }
    }
    for (int i = 0; i < N-1; i++) {
        if (data.at(i).at(data.at(i).size()-1) != data.at(i+1).at(0)) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
        s:Chars,
    }
    let mut rwhite = s.iter().filter(|&&x| x == '.').count() as i64;
    let mut rblack = s.iter().filter(|&&x| x == '#').count() as i64;

    let mut lwhite = 0;
    let mut lblack = 0;
    let mut ans = rwhite;
    const INF: i64 = 1 << 60;
    for (i, &c) in s.iter().enumerate() {
        if c == '.' {
            lwhite += 1;
            rwhite -= 1;
        } else {
            lblack += 1;
            rblack -= 1;
        }
        ans = min(lblack + rwhite, ans);
    }
    println!("{}", ans);
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll X, A, B;
    cin >> X >> A >> B;
    if (B - A <= 0) {
        cout << "delicious\n";
    }
    else if (B - A <= X) {
        cout << "safe\n";
    }
    else {
        cout << "dangerous\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int a[450];
	while(cin>>n)
	{
		for(int i=0;i<2*n;i++)
		{
			cin>>a[i];
		}
		sort(a,a+2*n);
//		for(int i=0;i<2*n;i++)
//			cout<<a[i]<<' ';
		int sum=0;
		for(int i=0;i<2*n;i+=2)
		{
			//cout<<i<<endl;
			sum+=a[i];
		}
			
		cout<<sum<<endl;	
	}	
	return 0;
}

Measured memory_bytes: 256
# input
S = input()

# process
def check(s, i, j):
    if (j-i)%2 == 1:
        l = (j-i-1)//2
        for s, t in zip(s[i:l], reversed(s[l+1:j])):
            if s != t:
                return False
    else:
        l = (j-i)//2
        for s, t in zip(s[i:l], reversed(s[l:j])):
            if s != t:
                return False
    return True        

result = check(S, 0, len(S))
result &= check(S, 0, (len(S)-1)//2)
result &= check(S, (len(S)+3)//2-1, len(S))

# output
print("Yes" if result else "No")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int main(){
  ll n,m;cin>>n>>m;
  string s,t;cin>>s>>t;

  ll gcm=n*m/gcd(n,m);

  rep(j,m){
    if((n*j)%m==0){
      if(t[j]!=s[(n*j)/m]){
        cout<<-1<<endl;
        return 0;
      }
    }
  }

  cout<<gcm<<endl;
}










Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x;
    else return ex(x*x,n/2);
};

int main(){
    int n,k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        int now = i;
        int cnt = 0;
        while(now < k){
            now *= 2;
            cnt++;
        }
        ans += 1.0/(n*(1<<cnt));
    } 
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,a,s,g;
    while(cin>>n>>a>>s>>g){
        if(n==0){exit(0);}
        vector<pair<pll,string>> A(a);
        for(auto &I:A){cin>>I.F.F>>I.F.S>>I.S;}
        vector<string> M(n,"{");
        M[g]="";
        for(int i=0;i<3*n;i++){
            for(auto &I:A){
                if(M[I.F.S]=="{"){continue;}
                else if(M[I.F.F]=="{"){M[I.F.F]=I.S+M[I.F.S];}
                else{M[I.F.F]=min(M[I.F.F],I.S+M[I.F.S]);}
            }
        }
        string ans=M[s];
        for(int i=0;i<3*n;i++){
            for(auto &I:A){
                if(M[I.F.S]=="{"){continue;}
                else if(M[I.F.F]=="{"){M[I.F.F]=I.S+M[I.F.S];}
                else{M[I.F.F]=min(M[I.F.F],I.S+M[I.F.S]);}
            }
        }
        if(ans!=M[s] || ans=="{"){cout<<"NO"<<endl;}
        else{cout<<ans<<endl;}
        if(ans!="{"){
            assert(!ans.empty());
            for(auto &I:ans){assert(I>='a' && I<='z');}
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 3448
import java.util.Scanner;
import java.util.Arrays;
import static java.lang.System.out;

public class Main {
	public static void main(String args[]) {
		new Main().run();
	}
	
	int toInt(String s) {
		return Integer.parseInt(s);
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int caseNumber = 1;
		while(true) {
			int W = sc.nextInt();
			if(W == 0) break;
			int N = sc.nextInt();

			int[] value = new int[N];
			int[] weight = new int[N];
			
			sc.skip("\n");
			
			for(int i = 0; i < N; i++) {
				String line = sc.nextLine();
				value[i] = toInt(line.split(",")[0]);
				weight[i] = toInt(line.split(",")[1]);
			}
			
			/*
			out.println("W: " + W);
			out.println("N: " + N);
			
			for(int i = 0; i < N; i++) {
				out.println("item: " + i + " -> " + value[i] + ":" + weight[i]);
			}
			*/
			
			int[][] dp = new int[N+1][W+1];
			for(int i = 0; i < N + 1; i++)
				for(int j = 0; j < W + 1; j++)
					dp[i][j] = 0;

			for(int item = 0; item < N; item++) {
				for(int cur = 0; cur <= W; cur++) {
					int v = value[item];
					int w = weight[item];

					if(w <= cur) {
						dp[item + 1][cur] = Math.max(dp[item][cur], dp[item][cur - w] + v);
					} else {
						dp[item + 1][cur] = dp[item][cur];
					}
				}
			}
			
			int ansWeight = W;
			int ansValue = dp[N][W];

			for(int j = W; j >= 0; --j) {
				if(dp[N][j] == ansValue)
					ansWeight = j;
			}
			
			out.println("Case " + caseNumber + ":");
			caseNumber++;
			out.println(ansValue);
			out.println(ansWeight);
		}
	}
}

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

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

  int ans=0,sum,tmp;
  for (int i=1; i<=n; i++) {
    sum=0;
    tmp=i;
    while (tmp) {
      sum += tmp%10;
      tmp /= 10;
    }
    if (sum>=a && sum<=b)
      ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

/*isOK関数は条件を自由に変えれば良い*/
bool isOK_a(int index,ll key,vector<ll> &v){
  if(v.at(index)<key)return true;
  else return false;
}

bool isOK_c(int index,ll key,vector<ll> &v){
  if(v.at(index)>key)return true;
  else return false;
}

//Aからはkey未満の最大ののインデックスを求める。つまりはleftが条件を満たす領域
int binary_search_a(ll key, vector<ll> &v){
  ll right = v.size();
  ll left = -1;
  
  while(right-left>1){
    ll mid = left+(right-left)/2;
    if(isOK_a(mid,key,v))left = mid;
    else right = mid; 
  }
  return left;
}

//Cからはkeyより大きいの最小のインデックスを求める。つまりはrightが条件を満たす領域
int binary_search_c(ll key, vector<ll> &v){
  ll right = v.size();
  ll left = -1;
  
  while(right-left>1){
    ll mid = left+(right-left)/2;
    if(isOK_c(mid,key,v))right = mid;
    else left = mid; 
  }
  return right;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> A(n),B(n),C(n);
  rep(i,n)cin >> A.at(i);
  rep(i,n)cin >> B.at(i);
  rep(i,n)cin >> C.at(i);
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  ll ans = 0;
  rep(i,n){
    //aはkey未満の最大のインデックスを求めそれに1足せば良い
    //cはkeyより大きい最小のインデックスを求め、nから引けば良い
    ll a = binary_search_a(B.at(i),A)+1;
    ll c = n-binary_search_c(B.at(i),C);
    ans += a*c;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <utility>
using namespace std;

template <typename T>
void print_vec(const vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; ++i) {
    if (i > 0) cout << ' ';
    cout << v[i];
  }
  cout << '\n';
}

int main() {

  string s;
  cin >> s;
  int r = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == 'R') {
      ++r;
    }
  }
  if (r == 2 && s[1] == 'S') {
    r = 1;
  }
  cout << r << '\n';
  return 0;
}


Measured memory_bytes: 3584
pln[14][14];
main(i,j,c,f){
	while(1){
		for(i=3;i<11;i++){
			for(j=3;j<11;j++)	pln[i][j]=getchar();
			if(getchar()==-1)	exit(0);
		}
		for(i=3;i<11;i++)for(j=3;j<11;j++)pln[i][j]-='0';
		getchar();

		f=1;
		for(i=3;f&&i<11;i++)for(j=3;f&&j<11;j++)
			if(pln[i][j]){
				if     (pln[i+3][j])	c='B';
				else if(pln[i][j+3])	c='C';
				else if(pln[i+2][j-1])	c='D';
				else if(pln[i+1][j+2])	c='E';
				else if(pln[i+2][j+1])	c='F';
				else if(!pln[i+1][j+1])	c='G';
				else	c='A';
				f=0;
			}
		printf("%c\n",c);
	}
}

Measured memory_bytes: 0
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<  #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }


void solve()
{ 
  int k;
  cin>>k;
  int ans=0;
  rep(i,1,k+1)
    {
        rep(j,1,k+1)
          {
            rep(l,1,k+1)
              ans+=__gcd(i,__gcd(j,l));

          }
    }
    cout<<ans;

}
signed main()
{fast
    int t;
  t=1;
   //cin>>t;
  while(t--)
     {
      solve();
     }



}
  













Measured memory_bytes: 3612
import java.util.*;

public class Main {
	double EPS = 10.e-08;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			long n = sc.nextLong();
			long target = 1;
			for(long i=2; i * i <= n; i++){
				if(n % i == 0){
					target = i;
				}
			}
			System.out.println(target - 1 + (n / target) - 1);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

int main(){
  long long int n, i;

  cin >> n;

  if(n <= -2){

  }else if(n == 0){
    cout << "1" << endl;
  }else if(n >= 1){
    for(i = n - 1;i >= 1;i--){
      n = n * i;
    }
    cout << n << endl;
  }


  return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=2000+10;
const int INF=int(1e8);
int maps[maxn];
int main() {
	int n,m,x;
	while(~scanf("%d %d %d",&n,&m,&x)) {
		memset(maps,0,sizeof(maps));
		int u;
		for(int i=1; i<=m; i++) {
			scanf("%d",&u);
			u;
			maps[u]=1;
		}
		int num1=0;
		int num2=0;
		for(int i=1; i<=x; i++) {
			if(maps[i]==1)
				num1++;
		}
		for(int i=x; i<=n; i++) {
			if(maps[i]==1)
				num2++;
		}
		int ans=min(num1,num2);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n;
ll k;
vector<int>a,b,c;

int main() {
	cin>>n>>k;
	a.resize(n);
	c.resize(n,-1);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	
	b.push_back(0);
	int p=0;
	ll i=0;
	while(true){
		i++;
		if(i==k){
			cout<<a[p]+1;
			return 0;
		}
		
		if(c[p]>=0){
			vector<int>::iterator it=find(b.begin(),b.end(),a[p]);
			int pos=it-b.begin();
			int m=(k-pos)%(b.size()-pos);
			cout<<b[pos+m]+1;
			return 0;
		}
		
		c[p]=a[p];
		b.push_back(a[p]);
		p=a[p];
	}

	
	return 0;
}

Measured memory_bytes: 5844
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int f[333][333][333];
int m,n,l,r,x,ans,size;
vector < pair < int , int > > rer[333];
inline void update(int &x,int y){ x=((long long)1*x+y+mod)%mod; }
int main()
{
    scanf("%d%d",&n,&m);
    for(register int i=1;i<=m;++i)
    {
        scanf("%d%d%d",&l,&r,&x);
        rer[r].push_back(make_pair(l,x));
    }
    f[1][0][0]=1;
    for(register int i=1;i<=n;++i)
    {
        size=rer[i].size();
        for(register int j=0;j<size;++j)
        {
            l=rer[i][j].first;x=rer[i][j].second;
            for(register int k=0;k<i;++k)
                for(register int p=0;p<=max(0,k-1);++p)
                {
                    if(x==1) { if(l<=k) f[i][k][p]=0; }
                    else if(x==2) { if(k<l||l<=p) f[i][k][p]=0; }
                    else { if(p<l) f[i][k][p]=0; }
                }
        }
        if(i==n) break ;
        for(register int j=0;j<i;++j)
            for(register int k=0;k<=max(0,j-1);++k)
                if(!f[i][j][k]) continue ;
                else
                {
                    update(f[i+1][j][k],f[i][j][k]);
                    update(f[i+1][i][j],f[i][j][k]);
                    update(f[i+1][i][k],f[i][j][k]);
                }
    }
    for(register int j=0;j<n;++j)
        for(register int k=0;k<=max(0,j-1);++k)
            update(ans,f[n][j][k]);
    ans=((long long)3*ans)%mod;
    printf("%d\n",ans);
    return 0;
}

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

string s;
int f=1;

int main()
{
	cin>>s;
	for(int i=0;i<s.size();++i) if(s[i]!=s[s.size()-i-1]) f=0;
	for(int i=0;i<(s.size()-1)/2;++i) if(s[i]!=s[(s.size()-1)/2-i-1]) f=0;
	for(int i=(s.size()+3)/2-1;i<s.size();++i) if(s[i]!=s[s.size()-i-1]) f=0;
	printf(f==1?"Yes":"No");
}

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

int main() {
  ll ans = 0;
  string s;
  cin >> s;
  if(s.size()==1) ans = stoll(s);
  else {
    for(int i=0; i<s.size(); i++) {
      for(int j=1; j<=s.size()-i; j++) {
        if(i==0 && j==s.size()) ans+=stoll(s);
        else if(i==0 || i==s.size()-j) ans+=(stoll(s.substr(i,j)))*pow(2,(s.size()-1-j));
        else ans+=(stoll(s.substr(i,j)))*pow(2,(s.size()-2-j));
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;
typedef long long ll;

struct bunsu {
	ll bunbo, bunshi;
	bunsu(ll a, ll b) {
		bunbo = b, bunshi = a;
	}
	bunsu() = default;
};

bunsu hiku (bunsu a, bunsu b){
	bunsu ret;
	ret = bunsu(b.bunbo * a.bunshi - a.bunbo * b.bunshi, a.bunbo * b.bunbo);
	return ret;
}

int main() {
	ll a;
	cin >> a;
	bunsu N(4, a);
	bunsu tmp;
	for (ll h = 1; h <= 3500; h++) {
		for (ll n = 1; n <= 3500; n++) {
			bunsu A(1, h), B(1, n);
			//cout << hiku(N, A).bunshi << "/" << hiku(N, A).bunbo << endl;
			bunsu tmp = hiku(hiku(N, A), B);
			//cout << h << " " << n << " " << tmp.bunshi << "/" << tmp.bunbo << endl;
			
			if (tmp.bunshi <= 0)continue;
			if (tmp.bunbo % tmp.bunshi == 0) {
				cout << h << " " << n << " " << tmp.bunbo / tmp.bunshi << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

vector<int> solve(int n, vector<int> b) {
    vector<int> ops;
    while (not b.empty()) {
        bool found = false;
        REP_R (i, b.size()) {
            if (b[i] == i) {
                ops.push_back(i);
                b.erase(b.begin() + i);
                found = true;
                break;
            }
        }
        if (not found) {
            return vector<int>(1, -2);
        }
    }
    reverse(ALL(ops));
    return ops;
}

int main() {
    int n; cin >> n;
    vector<int> b(n);
    REP (i, n) {
        cin >> b[i];
        -- b[i];
    }
    for (int op : solve(n, b)) {
        cout << op + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t a,b,c;
  cin >> a >> b >> c;
  
  if (c < a + b) cout << "No" << endl;
  else if (4 * a * b < (c - (a + b)) * (c - (a + b))) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[202020];
int B[202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i+1];
	
	vector<int> V;
	for(i=N;i>=1;i--) {
		int sum=0;
		for(x=i;x<=N;x+=i) sum^=B[x];
		
		if(sum!=A[i]) {
			B[i]=1;
			V.push_back(i);
		}
	}
	
	reverse(ALL(V));
	cout<<V.size()<<endl;
	FORR(v,V) cout<<v<<" ";
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
ll dfs(int K, const vector<vector<int>>& g, int now, int from) {
    int can_use_color;
    if (from == -1)can_use_color = K - 1;
    else can_use_color = K - 2;

    if (K <(int) g[now].size()) {
        return 0;
    }
    else {
        ll temp=1;
        for (auto e : g[now]) {
            if (e == from)continue;
            temp *= can_use_color;
            can_use_color--;
            temp %= MOD;
        }
        for (auto e : g[now]) {
            if (e == from)continue;
            temp *= dfs(K, g, e, now);
            temp %= MOD;
        }
        return temp;
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<vector<int>> g(N);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        g[a].push_back(b);
        g[b].push_back(a);
    }
    ll ans = K*dfs(K,g,0,-1);
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11648
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int main(void)
{
	priority_queue<int> qu;
	int n,m,a,i,s;
	long long sum;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&a);
		qu.push(a);
	}
	for(i=1;i<=m;i++){
		s=qu.top();
		qu.pop();
		qu.push(s/2);
	}
	sum=0;
	for(i=1;i<=n;i++){
		sum+=(long long)qu.top();
		qu.pop();
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 892
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int main(){
  int a[3];
  cin >> a[0];
  cin >> a[1];
  cin >> a[2];
  sort(a, a + 3);
  int ans = a[2] * 10 + a[1] + a[0];
  cout << ans << endl;
  return 0;
}


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

int main(){
  char A; cin >> A;
  if(A=='a'){ cout << 'b' << endl;}
  if(A=='b'){ cout << 'c' << endl;}
  if(A=='c'){ cout << 'd' << endl;}
  if(A=='d'){ cout << 'e' << endl;}
  if(A=='e'){ cout << 'f' << endl;}
  if(A=='f'){ cout << 'g' << endl;}
  if(A=='g'){ cout << 'h' << endl;}
  if(A=='h'){ cout << 'i' << endl;}
  if(A=='i'){ cout << 'j' << endl;}
  if(A=='j'){ cout << 'k' << endl;}
  if(A=='k'){ cout << 'l' << endl;}
  if(A=='l'){ cout << 'm' << endl;}
  if(A=='m'){ cout << 'n' << endl;}
  if(A=='n'){ cout << 'o' << endl;}
  if(A=='o'){ cout << 'p' << endl;}
  if(A=='p'){ cout << 'q' << endl;}
  if(A=='q'){ cout << 'r' << endl;}
  if(A=='r'){ cout << 's' << endl;}
  if(A=='s'){ cout << 't' << endl;}
  if(A=='t'){ cout << 'u' << endl;}
  if(A=='u'){ cout << 'v' << endl;}
  if(A=='v'){ cout << 'w' << endl;}
  if(A=='w'){ cout << 'x' << endl;}
  if(A=='x'){ cout << 'y' << endl;}
  if(A=='y'){ cout << 'z' << endl;}
  return 0;
}
  

Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
bool np[10010]; int pri[5010],cnt;
void getprime(int n)
{
	for(int i=2;i<=n;i++)
	{
		if(!np[i])	pri[++cnt]=i;
		for(int j=1;j<=cnt&&pri[j]*i<=n;j++)
		{
			np[pri[j]*i]=1;
			if(i%pri[j]==0)	break;
		}
	}
}
#define N 510
ll a[N][N];
ll lcm(ll x,ll y){if(!x||!y)return x+y;return x/__gcd(x,y)*y;}
int main()
{
	getprime(1e4); int n=read();
	if(n==2)	return puts("4 7\n23 10"),0;
	for(int i=1;i<=n;i++)	for(int j=1;j<=n;j++)
		if(!((i+j)&1))	a[i][j]=1ll*pri[i+j>>1]*pri[n+(i-j>>1)+(n+1>>1)];
	for(int i=1;i<=n;i++)	for(int j=1;j<=n;j++)
		if((i+j)&1)	a[i][j]=lcm(lcm(a[i-1][j],a[i+1][j]),lcm(a[i][j-1],a[i][j+1]))+1;
	for(int i=1;i<=n;i++,puts(""))	for(int j=1;j<=n;j++)
		printf("%lld ",a[i][j]);
	return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}




int main(){
  int n;
  cin>>n;
  vector<pair<int,int>>ab(n),cd(n);
  for(int i=0;i<n;i++){
    cin>>ab[i].first>>ab[i].second;
  }
  for(int i=0;i<n;i++){
    cin>>cd[i].second>>cd[i].first;
  }
  sort(ab.begin(),ab.end(),greater<pair<int,int>>());//降順
  sort(cd.begin(),cd.end());
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<ab.size();j++){
      if(ab[j].first<cd[i].second&&ab[j].second<cd[i].first){
                ans++;
                ab.erase(ab.begin()+j);
                break;
    }
  }
  }
  cout<<ans<<endl; 
}


  

Measured memory_bytes: 256
from sys import stdin

def gcd(a, b):
	while b: a, b = b, a % b
	return a

N, X = [int(x) for x in stdin.readline().rstrip().split()]
x_lst = sorted(set([abs(int(x)-X) for x in stdin.readline().rstrip().split()]))

if len(x_lst) == 1:
  print(x_lst[0])
else:
  prev_x = x_lst[0]
  for x in x_lst[1:]:
    prev_x = gcd(prev_x, x)
    if prev_x == 1: break
  print(prev_x)

Measured memory_bytes: 14480
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, a := intScanner(), intScanner()
	fmt.Println((h + a - 1) / a)
}


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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i = 0; i < N; i++) cin >> p.at(i);
  
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  
  int ans = p.at(0)/2;
  for(int i = 1; i < N; i++) ans += p.at(i);
  
  cout << ans << endl;
  
  return 0;
}

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



int main() {
    int n;
    cin >> n;
    
    cout << n * n * n << endl;
    
    
    return 0;
}




Measured memory_bytes: 3616
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int leg = s.length();

    int count = 0;
    
    for(int i = 0 ; i < leg/2 ; ++i){
      if(s.charAt(i) != s.charAt(leg-i-1)){
        count++;
      }

    }
    
    System.out.println(count);

  }
}


Measured memory_bytes: 35748
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 5) / 2 + 1
    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    private def innerLoop(j: Int, p: Int): Unit = {
      if(j <= top){
        setCmpst(j)
        innerLoop(j + p, p)
      }
    }

    private def loop(i: Int): Unit = {
      if(i <= sqrtLimit){
        if(isPrime(i)){
          val p = 2 * i + 3
          innerLoop((p * p - 3) >>> 1, p)
        }
        loop(i + 1)
      }
    }

    private def next(i: Int): Int =
      if ((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      loop(0)
      Iterator.single(2) ++ Iterator.single(3) ++ Iterator.iterate(5)(p => next((p - 1) >>> 1)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else if(n==2)println(1)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 66400
fn main() {
    let n = read::<usize>();
    let mut h = read_vec::<usize>();

    for i in 0..n-1 {
        if h[n - 1 - (i+1)] > h[n - 1 - i] {
            h[n - 1 - (i+1)] -= 1;
        }
    }

    for i in 0..n-1 {
        if h[i] > h[i+1] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

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

int main()
{
    while (true){
        int H;
        int W;
        cin >> H >> W;

        if (H==0 and W==0){
            break;
        }

        
        for (int i=0; i<H; i++){
            if (i%2==0){
                for (int j=0; j<W; j++){
                    if (j%2==0){
                        cout << "#";
                    }
                    else {
                        cout << ".";
                    }
                }
            }
            else {
                for (int j=0; j<W; j++){
                    if (j%2==0){
                        cout << ".";
                    }
                    else {
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;

            }

    }


Measured memory_bytes: 3080
S = input().rstrip()

if S == 'keyence': print('YES')
elif len(S) == 7: print('NO')
else:
	for length in range(len(S)-7):
		for i in range(len(S)-length):
			if S[0:i] + S[i+length+1:] == 'keyence':
				print('YES')
				exit(0)
	print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <climits>
#include <vector>
using namespace std;
typedef unsigned short ushort;

class blanch{
	public:
		bool visited;
		int distance;
		ushort from;
		ushort to;
};
typedef vector <blanch> vb;
typedef vector <vb> vvb;

int make_graph(vvb &graph, vb &nodes){

	int n=nodes.size();
	for (ushort i=0; i<n; i++){
		nodes[i].visited = false;
		nodes[i].distance = INT_MAX;
	}

	for (ushort i=0; i<n; i++){
		int i2, n2;
		cin>>i2;
		cin>>n2;

		blanch bl0;
		bl0.visited = false;
		bl0.from = i2;

		for (ushort j=0; j<n2; j++){
			ushort j2;
			cin>>bl0.to;
			cin>>bl0.distance;

			graph[i2].push_back(bl0);
		}
	}
	return 0;
}

int Shortest_Path(vvb &graph, vb &nodes){

	int n = graph.size(), p1=0;
	nodes[p1].distance = 0;
	int p2;
	while (p1 != -1){
		nodes[p1].visited=true;
		for (int i = 0; i < (int)graph[p1].size(); i++){
			blanch tmp = graph[p1][i];
			p2=tmp.to;
			if (nodes[p2].visited==false){
				int tmp2 = tmp.distance + nodes[p1].distance;
				if (tmp2 < nodes[p2].distance){
					tmp.distance = tmp2;
					nodes[p2] = tmp;
				}
			}
		}
		p1 = -1;
		int tmp;
		tmp = INT_MAX;
		for (int i=0; i<n; i++){
			if (nodes[i].visited==false && nodes[i].distance<tmp){
				p1 = i;
				tmp = nodes[i].distance;
			}
		}
	}
	return 0;
}

int resultout(vb &nodes){
	int n = nodes.size();
	for (int i=0; i<n; i++){
		cout<<i<<" "<<nodes[i].distance<<endl;
	}
	return 0;
}

int main(void){

	int n;
	cin>>n;
	vvb G(n, vb());
	vb nodes(n);

	make_graph(G, nodes);

	Shortest_Path(G, nodes);

	resultout(nodes);
	G.clear();
	nodes.clear();

	return 0;
} 

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

int main()
{
	int r;
	cin >> r;
	if(r < 1200){
		cout << "ABC\n";
	}else if(r < 2800){
		cout << "ARC\n";
	}else{
		cout << "AGC\n";
	}

	return 0;
}


Measured memory_bytes: 256
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200005)
#define MOD (1000000000ll + 7ll)
#define OO (1050000000)
#define OOL (1100000000000000000)

//global
ll a[N];
map<ll,int> act;
map<ll,int> ful;

vector<int> s;
bitset<100005> prim;

void fill(){
	int sqr = 100;
	s.push_back(2);
	for (int i = 3; i <= 10000; i += 2){
		if(!prim[i]){
			if(i <= sqr)
				for (int j = i*i; j <= 10000; j += i)
					prim[j] = true;
			s.push_back(i);
		}
	}
}

ll sqr(ll x){
	ll l = 1,r = x;
	while(l <= r){
		ll mid = (l+r)/2;
		ll ans = mid*mid;
		if(ans < x) l = mid+1;
		if(ans > x) r = mid-1;
		if(ans == x) return mid;
	}
	return 0;
}

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	fill();
	int n;
	cin >> n;	
	rep(i,0,n){
		cin >> a[i];
	}
	rep(i,0,n){
		vector<pair<int,int>> bs;
		for (int j = 0; j < sz(s) && s[j]*s[j] <= a[i]; ++j){
			int k = 0;
			while(a[i]%s[j] == 0){
				k++;
				a[i] /= s[j];
				if(k == 3) k = 0;
			}
			if(k) bs.push_back({s[j],k});
		}
		if(a[i] > 1){
			ll q = sqrtl(a[i]);
			if(q*q == a[i]) bs.push_back({q,2});
			else bs.push_back({a[i],1});
		}
		ll bsn = 1;
		ll rsn = 1;
		for(pair<int,int> w:bs){
			if(w.second == 1){
				bsn *= w.first;
				rsn *= w.first;
				rsn *= w.first;
			}
			if(w.second == 2){
				bsn *= w.first;
				bsn *= w.first;
				rsn *= w.first;
			}
		}
		if(bsn <= rsn) act[bsn]++;
		ful[min(bsn,rsn)]++;
	}
	int ans = 0;
	for(auto el:ful){
		if(el.first == 1) continue;
		ans += max(act[el.first],el.second-act[el.first]);
	}
	cout << ans+(act[1]>0);
	return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
 
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
void rw()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
 
int main()
{
    speed;
    //rw();
 
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
  
  	cout<<max({a*c,a*d,b*d,b*c});
  
    return 0;
}

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

#define int long long
bitset <1000005> one, two;

int arr[1000005];
vector <int> primes;

void sieve(){
    for(int i = 2; i <= 1000000; i++){
        if(!arr[i]){
            for(int j = i+i; j <= 1000000; j+=i){
                arr[j] = 1;
            }
        }
    }
    
    for(int i = 2; i <= 1000000; i++){
        if(!arr[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    sieve();
    
    int a, b;
    cin >> a >> b;
    
    one[1] = 1;
    two[1] = 1;
    
    for(auto i : primes){
        if(a%i == 0){
            one[i] = 1;
        }
        while(a%i == 0){
            a/=i;
        }
    }
    
    for(auto i : primes){
        if(b%i == 0){
            two[i] = 1;
        }
        while(b%i == 0){
            b/=i;
        }
    }
    
    int ans = 0;
    if(a!=1){
        ans += (a==b);
    }
    ans += ((one&two).count());
    
    cout << ans << '\n';
}





Measured memory_bytes: 9208
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
VI G[200011];

int C[200011];
int use[200011], usei;

VI ord;
int count_subtree(int v, int p, int ma) {
    ord.clear();
    ord.push_back(v);
    usei++;
    use[v] = usei;
    for (int i=0; i<(int)ord.size(); i++) {
	int x = ord[i];
	EACH (e, G[x]) if (*e != p && use[*e]<usei && *e < ma) {
	    ord.push_back(*e);
	    use[*e] = usei;
	}
    }
    return ord.size();
}

void dfs(int v, int p, int ma) {
    if (v < ma) {
	EACH (e, G[v]) if (*e != p) {
	    dfs(*e, v, ma);
	}
    } else {
	C[v] = C[p] + count_subtree(v, p, ma);

	EACH (e, G[v]) if (*e != p && *e < v) {
	    int cnt_small;
	    if (*e < ma) cnt_small = count_subtree(*e, v, ma);
	    else cnt_small = 0;

	    int cnt = count_subtree(*e, v, v);

	    EACH (f, ord) if (C[*f] == -1) {
		C[*f] = C[v] - cnt_small + cnt;
	    }
	}

	EACH (e, G[v]) if (*e != p) {
	    dfs(*e, v, v);
	}
    }
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }

    memset(C, -1, sizeof C);
    C[0] = 0;
    EACH (e, G[0]) {
	dfs(*e, 0, 0);
    }

    rprintf("%d", C+1, C+N);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 33784
import copy
from collections import deque
N,M = map(int,input().split())
lsside = [[] for i in range(N+1)]
lsline = []
for i in range(M):
    a,b = map(int,input().split())
    lsside[a].append(b)
    lsside[b].append(a)
    lsline.append([a,b])

ans = 0
lsloop = []
for i in range(M):
    graph = copy.deepcopy(lsside)
    a = lsline[i][0]
    b = lsline[i][1]
    graph[a].remove(b)
    graph[b].remove(a)
    used = [False for i in range(N+1)]
    ii = 1
    d = deque()
    d.append(a)
    used[a] = True
    while d:
        v = d.popleft()
        for i in graph[v]:
            if used[i]:
                continue
            ii += 1
            d.append(i)
            used[i] = True
    lsloop.append(ii)
ans = M - lsloop.count(N)
print(ans)

Measured memory_bytes: 9648
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 1000000007  # type: int


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

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

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

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

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

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


def main():
    N = int(input())
    P = list(map(int, input().split()))

    # 確定している道でグルーピングする
    uf = UnionFind(N)
    K = 0
    for i, p in enumerate(P):
        if p != -1:
            uf.union(i, p-1)
        else:
            K += 1

    # 階乗の事前計算
    factorial = [1]*K
    for i in range(K-1):
        factorial[i+1] = ((i+1)*factorial[i]) % MOD

    # 要請が未完のノードが属するグループサイズをメモ
    size_undef = [0]*K
    curr = 0
    for i, p in enumerate(P):
        if p == -1:
            size_undef[curr] = uf.size(i)
            curr += 1

    # dp[i, j]: i個の根付き木を見てj個を選んだ時の\sum{\prod_v S_v}
    # 「メモリ削減したdpとN^2確保するDP、どっちが早いんやろなあ」
    dp = [0]*(K+1)
    dp[0] = 1
    dp_new = dp[:]
    for i in range(1, K+1):
        for j in range(i):
            dp_new[j+1] += dp[j]*size_undef[i-1]
        dp = dp_new[:]

    # ただしj=1個を選んだ時のものは特別にsize[i]-1を考える必要がある
    if K >= 1:
        tot = 0
        for s in size_undef:
            tot += s-1
        dp[1] = tot

    # cycleをカウントする
    cycle_count = 0
    for i in range(1, K+1):
        # i個のグループからなるサイクルがひとつできる
        cycle_count += dp[i]*factorial[i-1]*pow(N-1, K-i, MOD)
        cycle_count %= MOD

    # すでに固定サイクルがあれば数える
    cycle_count += (uf.group_count()-K)*pow(N-1, K, MOD)

    # 求めます
    ans = N*pow(N-1, K, MOD) - cycle_count
    ans %= MOD

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 184676
import heapq
N,M=(int(x) for x in input().split())
a=list(map(int,input().split()))
a=list(map(lambda x: x*(-1),a))
heapq.heapify(a)
for _ in range(M):
    dai=heapq.heappop(a)
    heapq.heappush(a,(-1)*(dai*(-1)//2))
print((-1)*sum(a))


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N, C; cin >> N >> C;
    int d[31][31];
    for(int i=1; i<=C; i++) for(int j=1; j<=C; j++) cin >> d[i][j];

    map<int, int> mp0, mp1, mp2;
    for(int i=1; i<=N; i++) for(int j=1; j<=N; j++){
        int c; cin >> c;
        if((i+j)%3 == 0) mp0[c]++;
        else if((i+j)%3 == 1) mp1[c]++;
        else mp2[c]++;
    }

    ll ans = 1LL<<59;
    for(int c0=1; c0<=C; c0++){
        for(int c1=1; c1<=C; c1++){
            if(c0 == c1) continue;
            for(int c2=1; c2<=C; c2++){
                if(c0 == c2 || c1 == c2) continue;

                ll tmp = 0;
                for(int fr=1; fr<=C; fr++){
                    tmp += mp0[fr]*d[fr][c0];
                    tmp += mp1[fr]*d[fr][c1];
                    tmp += mp2[fr]*d[fr][c2];
                }
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256