akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n,d; cin>>n>>d;
    int x[n][d]; rep(i,n) rep(j,d) cin>>x[i][j];
    int cnt=0;
    double len;
    
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            len = 0;
            rep(k,d){
//                cout << "i:" << i << " j:" << j << " k:" << k << ln;
//                cout << "x[i][k]:" << x[i][k] << " x[j][k]:" << x[j][k] << ln;
                len += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            len = sqrt(len);
//            cout << len << ln;
            if(len == (int)len) cnt++;
        }
    }

    cout << cnt << ln;
    return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)


signed main()
{
    FIO;
    ll x,n,a,ans=LONG_LONG_MAX,val;vector<bool> v(201,false);
    cin>>x>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a;
        v[a]=true;
    }
    if(n==0)
    cout<<x;
    else
    {
        for(ll i=-200;i<0;i++)
        {
            if(abs(i-x)<ans)
            {
                ans=abs(i-x);
                val=i;
            }
        }
        for(ll i=0;i<=200;i++)
        {
            if(!v[i])
            {
                if(abs(i-x)<ans)
                {
                    ans=abs(i-x);
                    val=i;
                }
            }
        }
        cout<<val;
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return kai(n - 1)*n;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int n, x[105], y[105], h[105];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i] >> h[i];
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 101; j++) {
			int memo;
			for (int k = 0; k < n; k++) {
				if (h[k]) {
					memo = h[k] + abs(i - x[k]) + abs(j - y[k]);
					break;
				}
			}
			for (int k = 0; k < n; k++) {
				if (h[k] != max((int)0, memo - abs(i - x[k]) - abs(j - y[k])))goto loop;
			}
			cout << i << " " << j << " " << memo << endl;
			endre;
		loop:;
		}
	}
	endre;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<atcoder/all>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define show(x) cerr << #x << " = " << x << "\n";
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
#define pb(x) push_back(x)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
using namespace atcoder;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = INF;
class mint {
public:
	ll x;
	mint(ll x = 0) : x((x % mod + mod) % mod) {}
	mint operator-() const { 
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}
	friend ostream& operator<<(ostream& os, const mint& m){
		os << m.x;
		return os;
	}
};

ll modpow(ll x, ll n, ll p = INF) {
	if (n == 0) return 1 % p;
	if (n % 2 == 0) return modpow(x * x % p, n / 2, p);
	else return x * modpow(x, n - 1, p) % p;
}

ll op(ll a, ll b) {
    return max(a, b);
}

ll e() {
    return 0;
}

void Main(){

	ll N, K;
	cin >> N >> K;
	vl v(N);
	rep(i, N) cin >> v[i];
	rep(i, N) v[i] += (K + 5);

	segtree<ll, op, e> seg(300000 * 4 + 10);
	vl dp(N);
	dp[N - 1] = 1;
	seg.set(v[N - 1], 1);
	for(ll i = N - 2; i >= 0; i--){
		ll ma = seg.prod(v[i] - K, v[i] + K + 1);
		dp[i] = ma + 1;
		seg.set(v[i], dp[i]);
	}

	ll ans = MAX(dp);
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin >> t;
	rep(i, t) Main();
	return 0;
	
}





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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = m; i >= l; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define Count_bit(x)    __builtin_pop(x)
#define u_map           unordered_map
#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             2000000000
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 3e5;

int n, m, k, q, ans, a[N];
inline void Solve(){
    string t;
    cin >> t;
    if(t == "Sunny") cout << "Cloudy";
    else if(t == "Cloudy") cout << "Rainy";
    else cout << "Sunny";
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
	int a,b,c;cin>>a>>b>>c;
	if(a+b>=c)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MOD = 1e9+7;
int adj[25][25];
int dp[25][1<<21];

// gospers hack, https://en.wikipedia.org/wiki/Combinatorial_number_system#Applications
// find next k-combination
bool next_combination(unsigned long& x) // assume x has form x'01^a10^b in binary
{
    unsigned long u = x & -x; // extract rightmost bit 1; u =  0'00^a10^b
    unsigned long v = u + x; // set last non-trailing bit 0, and clear to the right; v=x'10^a00^b
    if (v==0) // then overflow in v, or x==0
        return false; // signal that next k-combination cannot be represented
    x = v + ((v^x)>>(__builtin_ctzl(u)+2)); // v^x = 0'11^a10^b, (v^x)/u = 0'0^b1^{a+2}, and x ← x'100^b1^a
    return true; // successful completion
}

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

    int n; cin>>n;

    FOR(i,n)
    FOR(j,n)
    cin>>adj[i][j];

    dp[0][0]=1;

    FOR(i,n)
    FOR(j,n) {
        unsigned long b = (1<<i)-1;
        do {
            int nb = b|(1<<j);
            if(nb==b) continue;
            if(!adj[i][j]) continue;
            dp[i+1][nb] += dp[i][b];
            dp[i+1][nb] %= MOD;
        } while(next_combination(b) && (b&(1<<n))==0);
    }

    cout<<dp[n][(1<<n)-1]<<endl;

    return 0;
}



Measured memory_bytes: 164096
N = int(input())
A = list(map(int, input().split()))
P = A[0]
Q = sum(A[1:])
m = abs(P-Q)
for i in range(1, N-1):
  P += A[i]
  Q -= A[i]
  m = min(m, abs(P-Q))
print(m)

Measured memory_bytes: 30740
-module('Main').
-export([main/1]).

main(_) ->
    {ok, [N]} = io:fread("", "~d"),
    F = N rem 10,
    io:format("~s~n", [yomi(F)]),
    halt().


yomi(0) ->
    "pon";
yomi(1) ->
    "pon";
yomi(2) ->
    "hon";
yomi(3) ->
    "bon";
yomi(4) ->
    "hon";
yomi(5) ->
    "hon";
yomi(6) ->
    "pon";
yomi(7) ->
    "hon";
yomi(8) ->
    "pon";
yomi(9) ->
    "hon".


Measured memory_bytes: 21876
#coding:UTF-8

def RoT(A,B,ans):
    if A:
        root=A[0]
        rindex=B.index(root)
        Aleft=A[1:rindex+1]
        Aright=A[rindex+1:]
        Bleft=B[:rindex]
        Bright=B[rindex+1:]
        RoT(Aleft,Bleft,ans)
        RoT(Aright,Bright,ans)
        ans.append(root)
        
        


if __name__=="__main__":
    n=int(input())
    A=input().split(" ")
    B=input().split(" ")
    ans=[]
    RoT(A,B,ans)
    print(" ".join(ans))

Measured memory_bytes: 7756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] ary = new int[3];
		for (int i =0; i <ary.length; i++){
			ary[i] = scan.nextInt();
		}
		if(ary[0] <= ary[2] && ary[2] <= ary[1]) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

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

int main(void){
    string s, t;
    cin >> s >> t;

    int cnt1 = 0;
    int cnt2 = 0;
    map<char, int> c1;
    map<char, int> c2;
    string ans="Yes";
    r(i,s.size()){
      if(c1[s.at(i)]==0){
        cnt1++;
        c1[s.at(i)]=cnt1;
      }
      if(c2[t.at(i)]==0){
        cnt2++;
        c2[t.at(i)]=cnt2;
      }
      if(c1[s.at(i)]!=c2.at(t.at(i))){
        ans="No";break;
      }
    }

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


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int x;
    cin >> x;
    if(400 <= x && x < 600) {
        cout << 8 << endl;
    }
    if(600 <= x && x < 800) {
        cout << 7 << endl;
    }
    if(800 <= x && x < 1000) {
        cout << 6 << endl;
    }
    if(1000 <= x && x < 1200) {
        cout << 5 << endl;
    }
    if(1200 <= x && x < 1400) {
        cout << 4 << endl;
    }
    if(1400 <= x && x < 1600) {
        cout << 3 << endl;
    }
    if(1600 <= x && x < 1800) {
        cout << 2 << endl;
    }
    if(1800 <= x && x < 2000) {
        cout << 1 << endl;
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B, Q;
	cin >> A >> B >> Q;
	ll INF = LLONG_MAX/100;
	vector<ll> s(A+2), t(B+2);
	REP(i, A) cin >> s[i+1];
	REP(i, B) cin >> t[i+1];
	s[0] = -INF;
	t[0] = -INF;
	s[A+1] = INF;
	t[B+1] = INF;

	REP(i, Q){
		ll x;
		cin >> x;
		ll SR = *lower_bound(s.begin(), s.end(), x) - x;
		ll TR = *lower_bound(t.begin(), t.end(), x) - x;
		ll sl = upper_bound(s.begin(), s.end(), x) - s.begin();
		ll tl = upper_bound(t.begin(), t.end(), x) - t.begin();
		ll SL = x - s[sl-1];
		ll TL = x - t[tl-1];
		//dump(SR)
		//dump(TR)
		//dump(SL)
		//dump(TL)
		ll tmp = INF*10;
		tmp = min(tmp, max(SL, TL));
		tmp = min(tmp, max(SR, TR));
		if(SL > TR) swap(SL, TR);
		if(SR > TL) swap(SR, TL);
		tmp = min(tmp, 2*SL+TR);
		tmp = min(tmp, 2*SR+TL);
		cout << tmp << endl;
	}
    return 0;
}

Measured memory_bytes: 2944
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;

#define F first
#define S second
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define fo(i, n)   for (int i = 1; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define fast  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define E cout << '\n'
const int N = 1e5 + 5;
int dp[4][N], a[4];
signed main(){
   fast;
   int n, k;
   cin >> n;

   for(int i = 1; i <= n; ++i) {
    cin >> a[1] >> a[2] >> a[3];
    for(int j = 1; j <= 3; ++j) {
        for(int k = 1; k <= 3; ++k) {
            if(k == j)
                continue;
            dp[j][i] = max(dp[j][i], dp[k][i-1] + a[j]);
        }
    }
   }
  /* fo(i, 3)
    fo(j, n)
        cout << dp[i][j] << " \n"[j == n];*/
   cout << max(max(dp[1][n], dp[2][n]), dp[3][n]);






   return 0;
}


Measured memory_bytes: 1408
// Coded by- Rad0n  275484HW

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define test int t,o;cin>>o;for(t=1;t<=o;t++)
#define kickstart int t,o;cin>>o;for(t=1;t<=o;t++){cout<<"Case #"<<t<<": ";solve();}
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll=long long int;
#define mod 1000000007
mt19937 rng(time(NULL));

void solve()
{
	string a,b;
	cin>>a>>b;
	b.pop_back();
	if(a==b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

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


Measured memory_bytes: 3628
a=[(2,380),(3,550),(5,850),(10,1520),(12,1870),(15,2244)]
dp=[1<<20]*51
for i,j in a:
    dp[i]=j
    for k in range(51-i):
        if dp[k]!=1<<20 and dp[k+i]>dp[k]+j:
            dp[k+i]=dp[k]+j
while 1:
    n=int(input())
    if n==0:break
    print(dp[n//100])

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

int main()
{

	string s;
	cin >> s;
	int result = 0;
	for(int i = 0;i < 3;i++)
	{
		if(s[i] == '1')
		{
			result++;
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
/************************************************
 * Au: Hany01
 * Date: Oct 14th, 2018
 * Prob: agc028c
 * Email: hany01dxx@gmail.com & hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
#define Rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define X first
#define Y second
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define SZ(a) ((int)(a).size())
#define ALL(a) a.begin(), a.end()
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

template <typename T> inline T read() {
	static T _, __; static char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


const int maxn = 1e5 + 5;

int main()
{
#ifdef hany01
	freopen("agc028c.in", "r", stdin);
	freopen("agc028c.out", "w", stdout);
#endif

	static int n, lss, A[maxn], B[maxn], cnt[maxn], mk[maxn][2], mk0, mk1;
	static PII ls[maxn << 1];

	For(i, 1, n = read<int>())
		ls[++ lss] = MP(A[i] = read<int>(), i), ls[++ lss] = MP(B[i] = read<int>(), i);

	sort(ls + 1, ls + 1 + lss);

	LL sum = 0;
	For(i, 1, n) ++ cnt[ls[i].Y], sum += ls[i].X;

	For(i, 1, n) if (cnt[i] == 2) { printf("%lld\n", sum); return 0; }

	For(i, 1, n)
		if (ls[i].X == A[ls[i].Y] && mk[ls[i].Y][0] == 0) mk[ls[i].Y][0] = 1, mk0 = 1;
		else assert(ls[i].X == B[ls[i].Y]), mk[ls[i].Y][1] = 1, mk1 = 1;

	if (mk0 ^ mk1) { printf("%lld\n", sum); return 0; }

	LL ans = LLONG_MAX;
	For(i, 1, n)
		if (mk[i][0])
			if (ls[n + 1].Y != i) chkmin(ans, sum - A[i] + ls[n + 1].X);
			else chkmin(ans, sum - A[i] + ls[n + 2].X);
		else
			if (ls[n + 1].Y != i) chkmin(ans, sum - B[i] + ls[n + 1].X);
			else chkmin(ans, sum - B[i] + ls[n + 2].X);
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
struct position{
    int now = -1;
    int maximum = -1;
};
int main(){
    string s;
    cin >> s;
    map<char,position> data;
    rep(i,0,s.size()){
        int now_dis = i - data[s[i]].now -1;
        data[s[i]].maximum = max(now_dis,data[s[i]].maximum);
        data[s[i]].now = i;
    }
    int ans = 1000000;
    for(auto x: data){
        int a = s.size()-data[x.first].now -1;
        data[x.first].maximum = max(data[x.first].maximum,a);
        ans = min(ans,data[x.first].maximum);
    }
    cout<<ans<<endl;
    
    


    return 0;
}

Measured memory_bytes: 3612
def A():
    temp = input().split()
    print(''.join(temp[::-1]))

def B():
    temp = [int(n) for n in input().split()]
    A = temp[0]
    B = temp[1]
    K = temp[2]
    to_minus = min(A, K)
    A -= to_minus
    K -= to_minus
    if K > 0:
        B -= min(B, K)
    print (A, B)

B()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define INF (1<<29)
const int MAX=210;

int N,M,R;
int dist[MAX][MAX];


int main() {
    cin>>N>>M>>R;
    vector<int>vr;
    for(int i=0;i<R;i++){
        int r;
        cin>>r;
        --r;
        vr.push_back(r);
    }
    
    // Floyd-Warshall の初期化: dist[i][i] = 0 に注意
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i!=j) dist[i][j]=INF;
        }
    }
    
    // 入力と Floyd-Warshall
    for(int i=0;i<M;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        dist[a][b]=c;
        dist[b][a]=c;
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    
    ll res=INF;
    sort(vr.begin(),vr.end());
    do {
        long long tmp = 0;
        for (int i = 1; i < vr.size(); ++i) tmp += dist[vr[i]][vr[i-1]];
        res = min(res, tmp);
    } while (next_permutation(vr.begin(), vr.end()));
    
    cout<<res<<endl;
}

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

using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		int count = 0;
		for(int i = 1; i <= n/2; i++){
			int sum = 0;
			for(int j = i; sum < n; j++){
				sum += j;
				if(sum == n){
					count++;
					break;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    cout << *max_element(all(a)) - *min_element(all(a)) << endl;
    return 0;
}


Measured memory_bytes: 888
#define _AOJ_
#include "bits/stdc++.h"
using namespace std;
typedef long long i64;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<b;++i)
#define all(c) c.begin(),c.end()

int main(){
	i64 h,w; cin>>w>>h;
	vector<i64>a(h),b(w);
	rep(i,w)cin>>b[i];
	rep(i,h)cin>>a[i];
	sort(all(a),greater<i64>());
	sort(all(b),greater<i64>());

	rep(i,h){
		rep(j,w){
			if(a[i]>0&&b[j]>0){
				--a[i],--b[j];
			}
		}
		sort(all(b),greater<i64>());
	}
	bool ok=1;
	rep(i,h)if(a[i])ok=0;
	rep(j,w)if(b[j])ok=0;
	cout<<ok<<endl;
}

//sub-EOF


Measured memory_bytes: 3160
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;

    if (V <= W) {
        cout << "NO" << endl;
        return 0;
    } else if ((V-W) * T < abs(A-B)) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;

int main() {
    int n; cin >> n;
    vector<int64_t> arr(n);
    map<int64_t, int64_t> mp;
    rep(i, n) {
        cin >> arr[i];
        mp[arr[i]]++;
    }

    int64_t sm = 0;
    rep(i, n) {
        sm += arr[i];
    }

    int64_t q; cin >> q;
    rep(i, q) {
        int64_t b, c; cin >> b >> c;
        int64_t cnt = mp[b];
        mp[b] -= cnt;
        mp[c] += cnt;
        sm = sm + (c - b) * cnt;
        cout << sm << endl;
    }
}


Measured memory_bytes: 9488
N, K = map(int, input().split())
A = list(map(int, input().split()))

sumA = sum(A)
candiate = []
# sumAの約数を列挙する
tmp = 1
while tmp * tmp <= sumA:
    if sumA % tmp == 0:
        candiate.append(tmp)
        candiate.append(sumA // tmp)
    tmp += 1

def f(x):
    A.sort(key=lambda z:z%x)
    tmp = 0
    judge = True
    for a in A:
        if tmp + (a % x) <= K and judge:
            tmp += a % x
        else:
            judge = False
            tmp -= x - (a % x)
        if tmp < 0: return False
    return True
ans = -1
for cand in candiate:
    if f(cand):
        ans = max(ans, cand)

print(ans)


Measured memory_bytes: 68712
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n & 1){
		float x=n+1;
		cout<<x/(2.0*n)<<endl;
	}
	else{
		float x=n;
		cout<<x/(2.0*n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
li = list(map(int, input().split()))

even = []
odd = []

for index, i in enumerate(li):
    if index % 2 == 0:
        even.append(i)
    elif index % 2 != 0:
        odd.append(i)

from collections import Counter
so_ev = Counter(even).most_common(2)
so_od = Counter(odd).most_common(2)

if so_ev[0][0] == so_od[0][0]:
    if len(so_ev) == 1 and len(so_od) == 1:
        print(n - so_ev[0][1])
    else:
        print(min(n - so_ev[1][1] - so_od[0][1], n - so_ev[0][1] - so_od[1][1]))
else:
    print(n - so_ev[0][1] - so_od[0][1])


Measured memory_bytes: 15856
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N; double A[101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	double up = 1;
	double down = 0;
	rep(i, 0, N) down += 1.0 / A[i];
	double ans = up / down;

	printf("%.10f\n", ans);
}







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

using namespace std;

vector<pair<long long, long long>> prime_factorize(long long N) {
	vector<pair<long long, long long>> res;
	for(long long i = 2; i * i < N; i++) {
		if (N % i != 0) { continue; }
		long long ex = 0;

		while (N % i == 0) {
			++ex;
			N /= i;
		}
		res.push_back({i, ex});
	}
	if (N != 1) {
		res.push_back({N, 1});
	}
	return res;
}


int main() {
	long long N;
	cin >> N;

	if ( N <= 1) {
		cout << 0 << endl;
		return 0;
	}

	auto list = prime_factorize(N);
	//for (auto a : list) {
	//		cout << "{ " << a.first << " " << a.second << " }" << endl;
	//}
	//cout << endl;

	int ans = 0;
  for (auto p : list) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3156
#include <stdio.h> 
#include <string.h>

int main() {
	int a = 0;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
	int y = 0;
	int m = 0;
	int d = 0;
	scanf("%d %d %d", &y, &m, &d);
	int y1 = 0;
	int b = 0;
	int g = 0;
	y1 = y+1;
	for (int i = y1; i < 1000; i++) {
		b = i%3;
		if (b != 0) {
			g = g + 195;
		}
		else if (b == 0) {
			g = g + 200;
		}
	}
	int m1 = 0;
	int g1 = 0;
	m1 = m - 1;
	b = y % 3;
	if(b!=0){
	for (int i = 1; i < m1+1; i++) {
		b = i % 2;
		if (b != 0) {
			g1 = g1 + 20;
		}
		else if (b == 0) {
			g1 = g1 + 19;
		}
	}
	}else if(b==0){
	    for (int i = 0; i < m1; i++) {
			g1 = g1 + 20;
		
	}
	}
	g1 = g1 + d;
	int g2 = 0;
	b = y % 3;
	if (b != 0) {
		g2 = 195;
	}
	else if (b == 0) {
		g2 = 200;
	}
	int g3 = 0;
	g3 = g2 - g1;
	g = g + g3;
	g = g + 1;
	printf("%d\n", g);
	}
	return 0;
}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, mp[10][10];

signed main(){
    cin >> N;
    FOR(i, 1, N + 1){
        string str = to_string(i);
        mp[str.front() - '0'][str.back() - '0']++;
    }
    ll ans = 0;
    REP(i, 10){
        REP(j, 10){
            ans += mp[i][j] * mp[j][i];
        }
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3696
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long
 
const int maxn=1e5+5;
 
int n,m;
bool bo[maxn];
int a[maxn],b[maxn],c[maxn];
 
int read() {
    int x=0,f=1;char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
    for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
    return x*f;
}
 
struct node {
    ll v;
    int u;
 
    node() {}
     
    node(int _u,ll _v) {u=_u,v=_v;}
 
    bool operator<(const node &a)const {
        return v<a.v;
    }
};
 
struct Heap {
    int tot;
    node tree[maxn];
     
    void ins(node x) {
        tree[++tot]=x;
        int pos=tot;
        while(pos>1) {
            if(tree[pos]<tree[pos>>1])
                swap(tree[pos],tree[pos>>1]),pos>>=1;
            else break;
        }
    }
 
    int pop() {
        node res=tree[1];
        tree[1]=tree[tot--];
        int pos=1,son=2;
        while(son<=tot) {
            if(son<tot&&tree[son|1]<tree[son])son|=1;
            if(tree[son]<tree[pos])
                swap(tree[son],tree[pos]),pos=son;
            else break;son=pos<<1;
        }
        return res.u;
    }
}T;
 
struct graph {
    int tot,h,t;
    ll dis[maxn],cnt[maxn];
    int list[maxn],deg[maxn];
    int now[maxn],pre[maxn],son[maxn],val[maxn];
 
    void clear() {
        tot=0;memset(now,0,sizeof(now));
        memset(deg,0,sizeof(deg));
    }
     
    void add(int a,int b,int c) {
        pre[++tot]=now[a];
        now[a]=tot;son[tot]=b;
        val[tot]=c;deg[b]++;
    }
 
    void dij(int st) {
        memset(dis,63,sizeof(dis));
        dis[st]=0;T.ins(node(st,0));
        while(T.tot) {
            int u=T.pop();
            for(int p=now[u],v=son[p];p;p=pre[p],v=son[p])
                if(dis[v]>dis[u]+val[p]) {
                    dis[v]=dis[u]+val[p];
                    T.ins(node(v,dis[v]));
                }
        }
    }
 
    void calc(int st) {
        cnt[st]=1;list[0]=st;h=0,t=1;
        while(h!=t) {
            int u=list[h++];
            for(int p=now[u],v=son[p];p;p=pre[p],v=son[p]) {
                cnt[v]+=cnt[u];
                if(--deg[v]==0)list[t++]=v;
            }
        }
    }
}G1,G2;
 
int main() {
    n=read(),m=read();
    for(int i=1;i<=m;i++) {
        a[i]=read(),b[i]=read(),c[i]=read();
        G1.add(a[i],b[i],c[i]);G2.add(b[i],a[i],c[i]);
    }G1.dij(1),G2.dij(2);
    G1.clear(),G2.clear();
    for(int i=1;i<=m;i++)
        if(G1.dis[a[i]]+G2.dis[b[i]]+c[i]==G1.dis[2]) {
            bo[i]=1;
            G1.add(a[i],b[i],c[i]),G2.add(b[i],a[i],c[i]);
        }
    G1.calc(1),G2.calc(2);
    for(int i=1;i<=m;i++) {
        if(bo[i]) {
            if(G1.cnt[a[i]]*G2.cnt[b[i]]==G1.cnt[2])puts("SAD");
            else puts("SOSO");
        }
        else {
            if(G1.dis[b[i]]+c[i]+G2.dis[a[i]]<G1.dis[2])puts("HAPPY");
            else puts("SOSO");
        }
         
    }
    return 0;
}



Measured memory_bytes: 12016
import sys
def main():
  N = int(input())
  
  print(0, flush = True)
  s = str(input())
  if s == "Vacant":sys.exit()
  l = [0, s]
  
  print((N-1), flush = True)
  r =  [N-1, str(input())]
  if r[1] == "Vacant":sys.exit()
  
  while True:
    print((l[0] + r[0])//2, flush = True)
    c = [(l[0] + r[0])//2, str(input())]
    if c[1] == "Vacant":sys.exit()
    if ((c[0]-l[0])%2 == 1 and c[1] == l[1]) or (c[0]-l[0])%2 == 0 and c[1] != l[1]:
      r = c
    else:
      l = c
          
if __name__ == "__main__":
  main()

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    int n;
    cin >> n;
    vector<int> c(n), v(n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    for(int i = 0; i < n; i++){
        if(v[i]-c[i]>0){
            ans += v[i]-c[i];
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			int[][] dp = new int[H][W];
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					dp[i][j] = 0;
				}
			}
			int[][] field = new int[H][W];
			for(int i=0; i<H; i++) {
				String str = sc.next();
				for(int j=0; j<W; j++) {
					field[i][j] = str.charAt(j) - '0';
				}
			}
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					dp[i][j] = field[i][j];
					if(i+j == 0) {
						continue;
					}
					else if(i == 0) {
						dp[i][j] += dp[i][j-1];
					}
					else if(j == 0) {
						dp[i][j] += dp[i-1][j];
					}
					else {
						dp[i][j] += Math.min(dp[i][j-1], dp[i-1][j]);
					}
				}
			}
			System.out.println(dp[H-1][W-1]);
		}
	}

}




Measured memory_bytes: 26488
#include <stdio.h>

int main(){
int w,n,i,f;
int a[31],b,c;

scanf("%d",&w);
for(i=1;i<=w;i++){
a[i]=i;
}
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d,%d",&b,&c);
f=a[c];
a[c]=a[b];
a[b]=f;
}
for(i=1;i<=w;i++){
printf("%d\n",a[i]);
}
return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

/*
 * @author Tanzim Ibn Patowary
 * Created  May 13, 2020 1:21:16 PM
 */
public class Main{

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		int statement = 0;
		statement = num%10;
		if (statement == 2 || statement == 4 || statement == 5 || statement == 7 || statement == 9) {
			System.out.print("hon");
		} else if (statement == 0 || statement == 1 || statement == 6 || statement == 8) {
			System.out.print("pon");
		} else if (statement == 3) {
			System.out.print("bon");
		}
	}
}


Measured memory_bytes: 27076
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[100010],adj1[100010],vis(100010,0),dis(100010,0),par(100010,0);
int myrandom (int i) { return std::rand()%i;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n;
    cin>>n;
    vector<long long> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    long double num=0;
    for(int i=0;i<n;i++)
    {
        num=num+(long double)(1/(v[i]*1.0));
    }
    long double ans=1/(num*1.0);
    cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------


// 絶対値
ll llabs(ll &a) { return (a < 0) ? (-a) : (a); }

// main -----------------------------------------------

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll one_count = 0;
    REP(i, n){
        cin >> a[i];
        if(a[i] == 1){
            one_count ++;
        }
    }
    if(one_count == 1){
        cout << 1 << endl;
        return 0;
    }else if(one_count >= 2){
        cout << 0 << endl;
        return 0;
    }

    sort(a.begin(), a.end());

    vector<bool> seen(1010100, false);
    vector<ll> isans(1010100, true);

    REP(i, n){
        if(seen[a[i]]){
            isans[a[i]] = false;
            continue;
        }
        if(isans[a[i]] == false){
            continue;
        }
        seen[a[i]] = true;
        for(ll k = a[i] * 2; k < 1010100; k += a[i]){
            isans[k] = false;
        }
    }

    ll ans = 0;
    REP(i, n){
        if(isans[a[i]]){
            ans ++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12712
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int N=1e6+10;
const int mod=998244353;
int h[N],e[N],ne[N],idx;
int f[N],g[N];
ll sum[3][N];
int sz[3];
void add(int a,int b)
{
    e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}
int inv;
ll qmi(int a,int b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)ans=(ans*a)%mod;
        a=((ll)a*a)%mod;
        b>>=1;
    }
    return ans;
}
ll gs(int a,int b)
{
    return qmi(a,b);
}
int main()
{
    int n;
    cin>>n;
    inv=qmi(qmi(10,18),mod-2);
    for(int i=0;i<3;i++)
    {
        int m;
        cin>>m;
        memset(h,-1,sizeof h);
        idx=0;
        for(int j=0;j<m;j++)
        {
            int a,b;
            scanf("%d%d",&a,&b);
            if(a>b)swap(a,b);
            add(a,b);
        }
        memset(g,0,sizeof g);
        ll now=gs(10,18*n);
        int num=0;
        for(int j=n;j>=1;j--)
        {
            num++;
            for(int k=h[j];k!=-1;k=ne[k])
            {
                g[f[e[k]]]=num;
            }
            f[j]=0;
            while(g[f[j]]==num)f[j]++;
            // cout<<f[j]<<endl;
            sz[i]=max(sz[i],f[j]);
            ll&v=sum[i][f[j]];
            // cout<<now<<endl;
            v=(v+now)%mod;
            now=(now*inv)%mod;
        }
    }
    ll ans=0;
    // cout<<sz[1]<<endl;
    for(int i=0;i<=sz[0];i++)
    {
        for(int j=0;j<=sz[1];j++)
        {
            int k=i^j;
            ans=(ans+sum[0][i]*sum[1][j]%mod*sum[2][k]%mod)%mod;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define ll long long
#define P 1000000007
using namespace std;
int n;
ll a[300005], wei[100];
ll ans;
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j <= 60; j++) {
			if(a[i] & ((ll)1 << j)) wei[j]++;//这个数的第j位是1,则这一位1的总数加1 
		}
	}
	for(int i = 0; i < 60; i++) {
		ans = (ans + (((wei[i] % P) * ((n - wei[i]) % P)) % P * (((ll)1 << i) % P)) % P) % P;//wei[i]表示有多少个1,n - wei[i]表示有多少个0   我就不信我每个都给它模还会错 
	}
//	for(int i = 0; i <= 60; i++) {//转换成二进制的每一位
//		ll t = 0, f = 0;
//		for(int j = 0; j < n; j++) {//每一个数的第i位
//			if(a[j] & ((ll)1 << i)) t++;//是1
//			else f++;//是0
//		}
//		ans = (ans + (t * (f * ((ll)1 << i) % P) % P) % P) % P;//相同为0,不同为1,二进制下第i位要乘 2 ^ i
//	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

int main(void){
	ll n,m; cin>>n>>m;

	ll s,c,seed=0,ans=0;
	s = n; c = m;
	if(s < c){
		seed = c - 2*s;
		if(seed < 0) seed = 0;
		ans = s + (seed / 4);
		printf("%lld\n", ans);
	}
	else{
		ans = c / 2;
		printf("%lld\n", ans);
	}	

	return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int ans =1;
   for(int i=1;i<9;i++)
   {
     if(ans == N) break; 
     else if(ans>N)
     {

       ans= ans/2;
       break;
     }
     ans*=2;
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MOD 1000000007
signed main() {
	int n;
	cin >> n;
	int ans = n;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)ans = ans * (i - 1) / i;
		while (n % i == 0) {
			n /= i;
		}
	}
	if (n != 1)ans = ans * (n - 1) / n;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3080
/* This Template is property of Pranav Khiste aka desmond_kaneki*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi(x,n) for(ll i=x;i<n;i++)
#define fj(x,n) for(ll j=x;j<n;j++)
#define vll vector<ll>
#define pb push_back
#define qll queue<ll>
#define mp make_pair
#define fst first
#define snd second
#define pll pair<ll,ll>
#define vpll vector<pll>
#define debug(x) cout<<#x<<' '<<x<<endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'
#define mod 1000000007
#define SUP LLONG_MAX
#define INF LLONG_MIN
#define test() ll var;  cin>>var; while(var--)
#define fileio freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);  // use cin cout only!!
main()
{
    //fastio;
    ll n;
    cin>>n;
    ll ar[n];
    fi(0,n)
        cin>>ar[i];
    ll stock=0,money=1000;
    //fi(0,n)
    {
        ll cur=0;
        stock = money/ar[cur];
        money = money%ar[cur];
        while(cur<n-1)
        {
            if(ar[cur+1]<ar[cur])
            {
                money = money + stock*ar[cur];
                stock=0;
            }
            else
            {
                stock = stock + money/ar[cur];
                money = money%ar[cur];
            }
            cur++;
        }
        money=money+stock*ar[n-1];
        stock=0;
    }
    cout<<money<<endl;


}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.DP
{
    class AOJshiritori
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt() + 1;
            string[] strs = new string[n];
            strs[0] = "A";
            for (int i = 1; i < n; i++) strs[i] = Read();

            int[] dp = new int[n];
            dp[0] = 0;
            var dict = new Dictionary<char, int>();
            for(int i = 1; i < n; i++)
            {
                dp[i] = dp[i - 1] + 1;
                if (dict.ContainsKey(strs[i][0]))
                {
                    dp[i] = Min(dp[i], dp[dict[strs[i][0]]]);
                    dict[strs[i][0]] = i;
                }
                else
                {
                    dict.Add(strs[i][0], i);
                }
            }
            WriteLine(dp[n-1]);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 28796