akhauriyash/Code-Regression huggingface dataset:
/*
 *
 *	Author: r3gz3n
 *	Description: 
 *	Difficulty: 
 *
 */

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define pi 3.141592653589793

using namespace std;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y); }
template<class T> inline T mod(T x) { if(x < 0) return -x; else return x; }

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;

const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(int argc, char* argv[])
{
	if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
	if(argc == 3) freopen(argv[2], "w", stdout);
	ios::sync_with_stdio(false);
	int s, k, ans = 0;
	cin >> k >> s;
	REP(x, 0, k+1, 1)
	{
		REP(y, 0, k+1, 1)
		{
			int z = s - x - y;
			if(z <= k and z >= 0)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
auto f(pii a,pii b){
    return to_string(a.second + 1) + " " +to_string(a.first + 1)+" " + to_string(b.second + 1) + " " +to_string(b.first + 1);
}
signed main(){
    int h,w; cin >> h >> w;
    int sum = 0;
    vector<vector<int>>g(h,vector<int>(w));
    rep(i,h)rep(j,w) cin >> g[i][j];
    vector<pii>v;
    rep(i,h)rep(j,w){
        sum += g[i][j];
    }
    vector<string>res;
    int ans = 0;
    
    rep(y,h)for(int x = w-1;x > 0;--x){
        if (g[y][x]%2 and g[y][x] != 0){
            ans ++;
            g[y][x-1]++;
            res.push_back(f(pii(x,y),pii(x-1,y)));
        }
    }
    rep(y,h-1){
        if(g[y][0]%2 and g[y][0] != 0){
            ans ++;
            g[y+1][0]++;
            res.push_back(f(pii(0,y),pii(0,y+1)));
        }
    }
    cout << ans << endl;
    erep(e,res)cout << e << endl;
}






Measured memory_bytes: 12916
N, M = map(int,input().split())
list = [list(input().split()) for i in range(M)]
flag_ac = [0] * N
penalty_score = [0] * N
ans_seitou = 0
ans_penalty = 0
for i in range(M):
    if list[i][1] == "AC":
        if flag_ac[int(list[i][0]) - 1] == 0:
            flag_ac[int(list[i][0]) - 1] = 1
            ans_seitou += 1
            ans_penalty += penalty_score[int(list[i][0]) - 1]

    if list[i][1] == "WA":
        if flag_ac[int(list[i][0]) - 1] == 0:
            penalty_score[int(list[i][0]) - 1] += 1

print(ans_seitou,ans_penalty)

Measured memory_bytes: 27448
#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)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


#define INF INT_MAX/2
string A, B;
int N;
//---------------------------------------------------------------------------------------------------
int isng() {
    if (count(B.begin(), B.end(), '1')) return 0;
    if (count(A.begin(), A.end(), '1')) return 1;
    return 0;
}
//---------------------------------------------------------------------------------------------------
int pre[2020], post[2020], L[2020], R[2020];
int sm[2020];
int f(int d) {
    int firs = -1;
    int last = 0;
    rep(i, 0, N) {
        if (firs < 0 && B[i] == '1') firs = i;
        if (B[i] == '1') last = i;
    }

    int p = last;
    rep(i, 0, N) {
        pre[i] = p;
        if (B[i] == '1') p = i;
    }
    p = firs;
    rrep(i, N - 1, 0) {
        post[i] = p;
        if (B[i] == '1') p = i;
    }

    sm[0] = 0;
    if (B[0] == '1') sm[0] = 1;
    rep(i, 1, N) {
        if (B[i] == '1') sm[i] = sm[i - 1] + 1;
        else sm[i] = sm[i - 1];
    }

    vector<pair<int, int>> v;
    int res = 0;
    rep(i, 0, N) {
        if (A[i] == B[(i + d) % N]) continue;
        res++;

        int a = i, b = (i + d) % N;
        int ss = -1;
        if (a <= b) {
            ss = sm[b];
            if (a) ss -= sm[a - 1];
        } else {
            ss = sm[N - 1];
            if (a) ss -= sm[a - 1];
            ss += sm[b];
        }
        if (ss) continue;

        int k = pre[i];
        L[i] = i - k;
        if (L[i] < 0) L[i] += N;

        int l = post[(i + d) % N];
        R[i] = l - (i + d) % N;
        if (R[i] < 0) R[i] += N;

        v.push_back({ L[i], R[i] });
    }
    sort(v.begin(), v.end(), greater<pair<int,int>>());

    int cur = INF, mx = 0;
    fore(p, v) {
        cur = min(cur, p.first + mx);
        mx = max(mx, p.second);
    }
    cur = min(cur, mx);
    res += 2 * cur + d;

    return res;
}
//---------------------------------------------------------------------------------------------------
int solve() {
    int ans = INF;
    rep(d, 0, N * 2) ans = min(ans, f(d));
    return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    N = A.length();

    if (isng()) {
        printf("-1\n");
        return;
    }

    int ans = INF;
    ans = solve();
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    ans = min(ans, solve());
    cout << ans << endl;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

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

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

int merge(vector<int> &as, int l, int mid, int r) {
    const auto n1  = mid - l;
    const auto n2  = r - mid;
    const auto lim = numeric_limits<int>::max();
    vector<int> L(n1 + 1);
    rep(i, 0, n1) {
        L[i] = as[l + i];
    }
    L[n1] = lim;
    vector<int> R(n2 + 1);
    rep(i, 0, n2) {
        R[i] = as[mid + i];
    }
    R[n2] = lim;
    int i = 0, j = 0;
    rep(k, l, r) {
        if (L[i] <= R[j]) {
            as[k] = L[i];
            i++;
        } else {
            as[k] = R[j];
            j++;
        }
    }
    return r - l;
}

int merge_sort(vector<int> &as, int l, int r) {
    if (abs(l - r) <= 1) return 0;

    auto mid = (l + r) / 2;
    int res  = 0;
    res += merge_sort(as, l, mid);
    res += merge_sort(as, mid, r);
    res += merge(as, l, mid, r);
    return res;
}

signed main() {
    int N;
    cin >> N;
    vector<int> S(N);
    rep(i, 0, N) cin >> S[i];
    int ans = merge_sort(S, 0, S.size());

    dump_vec(S);
    cout << ans << "\n";
}



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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int h, w, K;
char s[11][1123];

int main(){
	cin >> h >> w >> K;
	RC(i, h){
		cin >> s[i];
	}

	int min = INT_MAX;
	for(int i = 0; i < 1 << (h - 1); ++i){
		int tmp[11][1123] = {};
		int popcount = __builtin_popcount(i);
		for(Int j = 0; j < w; ++j){
			for(Int k = 0, l = 0; k < h; ++k){
				tmp[l][j] += s[k][j] == '1';
				if((i >> k) & 1) ++l;
			}
		}
		if( [&]{
			for(Int j = 0; j <= popcount; ++j){
				for(Int k = 0; k < w; ++k){
					if(tmp[j][k] > K){
						return 0;
					}
				}
			}
			return 1;
		}() ){
			/*
			for(Int j = 0; j <= popcount; ++j){
				for(Int k = 0; k < w; ++k){
					cout << tmp[j][k] << " ";
				}
				cout << endl;
			}
			*/
			int count[1123] = {};
			Int ans = 0;
			for(Int j = 0; j < w; ++j){
				for(Int k = 0; k <= popcount; ++k){
					count[k] += tmp[k][j];
					// cout << count[k] << " ";
				}
				if([&]{ for(Int k = 0; k <= popcount; ++k){
					if(count[k] > K) return 1;
				} return 0; }()){
					++ans;
					// cout << "!";
					for(Int k = 0; k <= popcount; ++k){
						count[k] = tmp[k][j];
					}
				}
				// cout << endl;
			}
			// cout << ans << " + " << popcount << " = ";
			ans += popcount;
			// cout << ans << endl;
			if(min > ans) min = ans;
		}
	}
	cout << min << endl;
}


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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"

set<ll> adj[100005];
vector<ll> a[100005]; 
map<pair<ll,ll>,ll> hm;

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

    // cout<<fixed<<setprecision(15);

    ll l,r;
    cin>>l>>r;

    ll ans = LONG_LONG_MAX;

    for(ll i = 0 ; i < 2020; i++)
    {
        for(ll j = 0 ; j < 2020 ; j++)
        {
            ll t1 = l + i;
            ll t2 = l + j;

            if(t1 != t2 && t1 <= r && t2 <= r)
            {
                ans = min(ans,(t1 * t2) % 2019);
            }

        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 7296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	// 
	static BufferedReader br;
	
	public static void main(String[] args) throws IOException{
		InputStreamReader in = new InputStreamReader(System.in);
		br = new BufferedReader(in);
		int n = ii();
		
		if(n%2==0) {
			System.out.println(n/2);
		}else {
			System.out.println(n/2+1);
		}
		
		
		br.close();
		
	}
	
	static private int ii() throws IOException{
		return Integer.parseInt(br.readLine());
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N;
	cin>>N;
	if(N<105)cout<<0;
	else if(N<135)cout<<1;
	else if(N<165)cout<<2;
	else if(N<189)cout<<3;
	else if(N<195)cout<<4;
	else cout<<5;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod =1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
// ----------------------DEBUG TEMPLATE--------------------------
#define N 100001
int dp[N][4];
vi a(N),b(N),c(N);

int solve(int day,int prev){
    if(day==0){
        return 0 ;
    }
    int op1=INT_MIN,op2=INT_MIN;
    if(dp[day][prev]>-1){
        return dp[day][prev];
    }
    if(prev==1){
        op1 = b[day] + solve(day-1,2);
        op2 = c[day] + solve(day-1,3);
    }
    if(prev==2){
        op1 = a[day] + solve(day-1,1);
        op2 = c[day] + solve(day-1,3);
    }
    if(prev==3){
        op1 = b[day] + solve(day-1,2);
        op2 = a[day] + solve(day-1,1);
    }
    return dp[day][prev] = max(op1,op2);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    
    Fo(i,1,n+1){
        cin>>a[i]>>b[i]>>c[i];
    }
    int res=INT_MIN;
    memset(dp,-1,sizeof(dp));
    res = max(res,solve(n,1)),
    memset(dp,-1,sizeof(dp));
    res = max(res,solve(n,2)),
    memset(dp,-1,sizeof(dp));
    res = max(res,solve(n,3)),
    cout<<res<<endl;
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MX = 100005;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

ll facs[MX], facInvs[MX];

void initFacs() {
	facs[0] = facInvs[0] = 1;
	for(int i = 1; i < MX; i++) {
		facs[i] = modMul(facs[i - 1], i);
		facInvs[i] = modInv(facs[i]);
	}
}

ll choose(ll a, ll b) {
	if (b > a) return 0;
	if (a < 0) return 0;
	if (b < 0) return 0;
    ll cur = facs[a];
    cur = modMul(cur, facInvs[b]);
    cur = modMul(cur, facInvs[a-b]);
    return cur;
}

ll N, K;
ll ans;

void solve() {
    initFacs();
    cin >> N >> K;
	vector<ll> a(N); for(auto& i : a) cin >> i;
    sort(a.begin(), a.end());
    // Summation of max
	for (int i = K - 1; i < N; ++i) {
		ll cnt = choose(i, K - 1);
		ll val = a[i] + MOD; val %= MOD;
		val *= cnt; val %= MOD;
		ans += val; ans %= MOD;
	}
	
	// Summation of min
	for (int i = 0; i < N - K + 1; i++) {
		ll cnt = choose(N - i - 1, K - 1);
		ll val = a[i] + MOD; val %= MOD;
		val *= cnt; val %= MOD;
		ans += MOD - val; ans %= MOD;
	}
	
	cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n) mp[a[i]]++;
    int num = 0;
    for (auto m: mp) {
        if (m.second>1) {
            num += m.second - 1;
        }
    }
    int x = (num-1)/2+1;
    int ans = n-num;
    if (ans%2==0) ans--;
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8204
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n, a, b = map(int, readline().rstrip().split())
    x = list(map(int, readline().rstrip().split()))
    sumX = 0
    for i in range(n-1):
        sumX += min(b, a * (x[i + 1] - x[i]))
    print(sumX)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20556
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int n = 0;
  string s;
  cin >> s;
  for (auto c : s)
  {
    n += (c == '+' ? 1 : -1);
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 300005
using namespace std;
typedef long long ll;
int n,a[N],d[N][25],s=1,cs,cx;
ll ans;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1,j=1;i<=n;i++){
        if(i<=n)
            cin>>a[i];
        cs+=a[i];
        cx^=a[i];
        while(cs!=cx){
            cs-=a[j];
            cx^=a[j];
            j++;
        }
        ans+=(ll)(i-j+1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;

using namespace std;

// ＜方針＞
// 累積xorを利用。
// グループ分けをしたときに各グループの要素全てのxorをAとすると、
// Aが0でない場合については
// 累積xorから  0→A→0→A→...→A→0  という部分列の取り出し方を求める問題になる。
// （累積xorが  0,0,A,*,A,0,0,*,*,A,A,0,A,*,A,*,0,*,0   みたいになっていて（*はA,0以外の数）   
//　 そこから 0,A,0,A,0,A,0 のような部分列の取り出し方の総数を求める）
// この計算を全てのAの値について足し合わせるので、単純にdpをすると計算時間が膨大になるが、
// Aのタイミングでだけdp値を更新する形にすれば計算量を抑えることができる。
// 具体的には
//    dp[i]   上記のような数列の1～i番目の項の中から、0,A,0,A,...,0,A   という部分列の取り出し方の数
//    dp0[i]  上記のような数列の1～i番目の項の中から、0,A,0,A,...,0,A,0 という部分列の取り出し方の数
// とおいて、Aのタイミングでだけdp値を求める。
// そのためには前回のAの位置を覚えておくことと、前回のAから今回のAまでの間に出てくる0の数を知ることが必要。
// 前者はAからlast index を知ることができるような map を持つ形、後者は0の個数の累積和を使った。

int main(int argc, char* argv[])
{
    int n;
    scanf("%ld", &n);

    vector<int> a(n), s(n+1), s0(n+1);
    int i;
    s[0]=0, s0[0]=1;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        s[i+1]=s[i]^a[i];
        s0[i+1]=s0[i]+((s[i+1]==0)? 1: 0);
    }

    map<int, int> z;   // val, previous index
    vector<ll> dp(n), dp0(n);
    dp0[0]=1;
    for(i=1; i<n; i++) {
        if(s[i]!=0) {
            int prev=z[s[i]];
            int num0 = s0[i]-s0[prev];
            dp0[i]=(dp[prev]*(num0)+dp0[prev])%MOD;
            dp[i]=(dp[prev]*(num0+1)+dp0[prev])%MOD;
            z[s[i]]=i;
        }
    }

    ll ans=1;
    if(s[n]==0) {
        for(i=0; i<s0[n]-2; i++) {
            ans = ans*2%MOD;
        }
        auto it=z.begin();
        for(; it!=z.end(); ++it) {
            ans = (ans + dp[it->second])%MOD;
        }
    }
    else {
        int prev=z[s[n]];
        int num0 = s0[n]-s0[prev];
        ans = (dp0[prev] + dp[prev]*num0)%MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 27392
n=int(input())
a=[int(input())for i in range(n)]
a_max=max(a)
index_max=a.index(a_max)
for i in range(n):
    if i==index_max:
        print(max(a[:index_max]+a[index_max+1:]))
    else:
        print(a_max)

Measured memory_bytes: 20116
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
ll m,n;
int a[100010];
string s; 
int main()
{
	cin>>n;
	while(n)
	{
		int x=n%26-1;
		if(x==-1) x=25;
		s+=char(x+'a');
		if(n%26==0) n-=26;
		n/=26;
	}
	string ans="";
	rep(i,s.size())
	{
		ans+=s[s.size()-i-1];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    REP(i, n) {
        cin >> v[i];
    }

    ll now = v.back();
    RREP(i, n-2, 0) {
        if (v[i] > now + 1) {
            std::cout << "No" << '\n';
            return 0;
        } else if (v[i] == now + 1) {
            ;
        } else {
            now = v[i];
        }
    }
    std::cout << "Yes" << '\n';

    return 0;
}


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

long long A[5];

int main(){
    int n, m, a, r ,c, h;
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s[0] == 'M') A[0]++;
        else if(s[0] == 'A') A[1]++;
        else if(s[0] == 'R') A[2]++;
        else if(s[0] == 'C') A[3]++;
        else if(s[0] == 'H') A[4]++;
    }
    long long ans = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                ans += A[i] * A[j] * A[k];                
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
from functools import reduce
from operator import xor

R = lambda: map(int, input().split())
 
n = int(input())
if n % 3:
    ans = 'YNeos'[any(R())::2]
else:
    a = sorted(R())
    m = n // 3
    if reduce(xor, a[::m]):
        ans = 'No'
    elif any(len(set(a[i:i + m])) > 1 for i in range(0, n, m)):
        ans = 'No'
    else:
        ans = 'Yes'
print(ans)


Measured memory_bytes: 14708
#define N 200005
#define INF 2000000000
#include <stdio.h>
int A[N];
int L[N / 2 + 2], R[N / 2 + 2];

long long merge(int A[], int left, int mid, int right) {
    long long cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1] = INF;
    R[n2] = INF;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
            cnt += n1 - i;  //这一步是整个算法的精髓
        }
    }
    return cnt;
}

long long mergeSort(int A[], int left, int right) {
    if (right > left + 1) {
        int mid = (left + right) / 2;
        long long v1 = mergeSort(A, left, mid);
        long long v2 = mergeSort(A, mid, right);
        long long v3 = merge(A, left, mid, right);
        return v1 + v2 + v3;
    }
    return 0;
}

int main() {
    long long cnt = 0;
    int n = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    cnt = mergeSort(A, 0, n);
    printf("%lld\n", cnt);
    return 0;
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
ll gcd(ll a, ll b){
    if(a < 0) a = -a;
    if(b < 0) b = -b;
    if(b == 0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a/g * b;
}

void solve(){
    ll n; cin >> n;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k=1; k<=n; k++){
                ll gcd1 = gcd(i, j);
                ll gcd2 = gcd(gcd1, k);
                sum += gcd2;
            }
        }
    }
    cout << sum << endl;
}

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define roop0(n) for(long long i = 0;i < n;i++)
#define roop1(n) for(long long i = 1;i < n;i++)
#define rep(i,a,b) for(long long i = a; i < b; i++)
#define print(a) for(auto x : a) cout << x << " "; cout << "\n"

using namespace std;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;

const static string el = "\n";
long long result = 0;

int main () {
  int x; cin >> x;
  if (400 <= x && x <= 599) {
    cout << 8 << endl;
  }
  if (600 <= x && x <= 799) {
    cout << 7 << endl;
  }
  if (800 <= x && x <= 999) {
    cout << 6 << endl;
  }
  if (1000 <= x && x <= 1199) {
    cout << 5 << endl;
  }
  if (1200 <= x && x <= 1399) {
    cout << 4<< endl;
  } 
  if (1400 <= x && x <= 1599) {
    cout << 3 << endl;
  }
  if (1600 <= x && x <= 1799) {
    cout << 2 << endl;
  }
  if (1800 <= x && x <= 1999) {
    cout << 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	var ans string
	for _, c := range s {
		switch c {
		case '0':
			ans += "0"
		case '1':
			ans += "1"
		case 'B':
			if len(ans) != 0 {
				ans = ans[:len(ans)-1]
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn=2e7+10;
const LL inf=300000000000000;
LL x[maxn];
struct AC
{
    struct zp
    {
        int lson,rson;
        LL sum;
    }tree[maxn];
    int cont,root;
    void init()
    {
        cont=0;
        root=-1;
    }
    int newnode()
    {
        tree[cont].lson=tree[cont].rson=-1;
        tree[cont].sum=0;
        cont++;
        return cont-1;
    }
    void update(int &k,LL l,LL r,LL num)
    {
        if(k==-1) k=newnode();
        tree[k].sum++;
        if(l==r) return ;
        LL mid=(l+r)>>1;
        if(num<=mid)
            update(tree[k].lson,l,mid,num);
        else
            update(tree[k].rson,mid+1,r,num);
    }
    LL query(int k,LL l,LL r,LL ql,LL qr)
    {
        if(k==-1) return 0;
        if(l==ql&&r==qr)
            return tree[k].sum;
        LL mid=(l+r)>>1;
        if(qr<=mid)
            return query(tree[k].lson,l,mid,ql,qr);
        else if(ql>mid)
            return query(tree[k].rson,mid+1,r,ql,qr);
        else
            return query(tree[k].lson,l,mid,ql,mid)+query(tree[k].rson,mid+1,r,mid+1,qr);
    }
}ac;
int main()
{
    int n;
    LL m;
    while(~scanf("%d%lld",&n,&m))
    {
        ac.init();
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&x[i]);
            x[i]-=m;
        }
        x[0]=0;
        for(int i=1;i<=n;i++)
            x[i]+=x[i-1];
      //  ac.update(ac.root,-inf,inf,0);
        LL ans=0,sum=0;
        for(int i=1;i<=n;i++)
        {
            ac.update(ac.root,-inf,inf,sum);
            ans+=ac.query(ac.root,-inf,inf,-inf,x[i]);
            sum=x[i];
        }
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 98560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		double[] P = new double[N+1];
		
		String[] S = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			P[i+1] = Double.parseDouble(S[i]);
		}
		
		int totalH = N/2 + 1;
		int totalT = N/2;
		
		double[][] cache = new double[N+1][totalT+1];
		cache[0][0] = 1;
		
		//only heads
		for(int i = 1; i <= N; i++) {
			cache[i][0] = P[i] * cache[i-1][0];
		}
		
		//only tails
		for(int i = 1; i <= totalT; i++) {
			cache[0][i] = (1- P[i]) * cache[0][i-1];
		}
		
		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= totalT; j++) {
				if(i +j > N) {
					continue;
				}
				
				cache[i][j] = (P[i+j] * cache[i-1][j]) + ((1- P[i+j]) * cache[i][j-1]);
			}
		}
		
		double result = 0;	
		while(totalT >= 0) {
			result += cache[totalH][totalT];
			totalT--;
			totalH++;
		}
		
		System.out.println(result);
	}
}


Measured memory_bytes: 77368
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<"\n";
#define lli long long int
int32_t main()
{  lli n,m,i,k,j,c=0,v1=0,v2=0;
   cin>>n>>m>>k;
   lli a[n+5];
   lli b[m+5];
   for(i=1;i<=n;i++)
    { cin>>a[i];
      if(i!=1) a[i]+=a[i-1];
      if(k>=a[i]) v1=i;
    }
   for(i=1;i<=m;i++)
    { cin>>b[i];
      if(i!=1) b[i]+=b[i-1];
      if(k>=b[i]) v2=i;
    }
   i=1;  j=m;
   c=max(v1,v2);
   while(i<=n && j>=1)
   {  if(a[i]+b[j] <=k)
       {   c=max(c,i+j);
           i++;
       }
       else
         j--;
   }
   cout<<c<<"\n";
   return 0;
}//main


Measured memory_bytes: 6676
n, m, k = map(int, input().split())
mod = 998244353
fac = [1 for _ in range(n+1)]
fac_inv = [1 for _ in range(n+1)]
memo = [1 for _ in range(n+1)]
for i in range(n):
    fac[i+1] = (fac[i] * (i+1)) % mod
    fac_inv[i+1] = pow(fac[i+1], mod-2, mod)
    memo[i+1] = memo[i] * (m-1) % mod

ans = 0
for i in range(0, k+1):
    ans = (ans + m * memo[n-i-1] * fac[n-1] * fac_inv[i] * fac_inv[n-i-1]) % mod

print(ans)

Measured memory_bytes: 32600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    sort(all(a));
    int b=a.back();
    if(b%2==0){
        int c=b/2,d=a.front();
        rep(i,n-1){
            if(abs(a.at(i)-b/2)<=c){
                d=a.at(i);
                c=abs(a.at(i)-b/2);
            }
        }
        cout<<b<<' '<<d<<endl;
    }else{
        double c=b/2.; int d=a.front();
        rep(i,n-1){
            if(abs(a.at(i)-b/2)<=c){
                d=a.at(i);
                c=abs(a.at(i)-b/2.);
            }
        }
        cout<<b<<' '<<d<<endl;
    }
}

Measured memory_bytes: 1024
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back
#define inf (1<<29)

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        int x; cin>> x;
        if(x<1200)cout<<"ABC"<<endl;
        else cout<<"ARC"<<endl;


return 0;
}



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

typedef long long ll;
typedef pair<ll, ll> pii;

#define MOD 1000000007
#define xx first
#define yy second

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

    if(a > b)
    {
        cout << 0 << endl;
        return 0;
    }

    long long MX = (n-1)*b+a;
    long long MN = (n-1)*a+b;
    cout << max(MX-MN+1, 0LL) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	int A1 = K;
	int A2 = K + 2 * N - 1;
	int B1 = A2 + 1;
	int B2 = K + 3 * N - 1;

	if (2 * (A1 + A2) <= B1 + B2) {

		int T = (N + 1) / 2;

		vector<int> X(N);
		vector<int> Y(N);
		vector<int> Z(N);
		for (int i = 0; i < T; i++) {
			X[i] = K + i;
			Y[i] = B1 - T + i;
			Z[i] = B1 + 2 * i;
		}
		for (int i = T; i < N; i++) {
			X[i] = K + T + i - T;
			Y[i] = A1 + N + (i - T);
			Z[i] = B1 + 1 + 2 * (i - T);
		}
		for (int i = 0; i < N; i++) {
			cout << X[i] << " " << Y[i] << " " << Z[i] << endl;
		}

	}
	else {
		cout << "-1" << endl;
	}
}

Measured memory_bytes: 4608
<?php
fscanf(STDIN, "%d %d", $n, $q);
for ($i = 0; $i < $n - 1; $i++) {
	fscanf(STDIN, "%d %d", $a, $b);
	$r[$b] = $a;
}
$c = array_fill(1, $n, 0);
while ($q--) {
	fscanf(STDIN, "%d %d", $p, $x);
	$c[$p] += $x;
}
$t = [$c[1]];
for ($i = 2; $i <= $n; $i++) {
	$t[] = $c[$i] += $c[$r[$i]];
}
echo implode(' ', $t);

Measured memory_bytes: 36468
#include<bits/stdc++.h>
using namespace std;
int n;
double xp0,yp0,xp1,yp1,xp2,yp2,xp3,yp3,l1,r1,l2,r2,sum;
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xp0,&yp0,&xp1,&yp1,&xp2,&yp2,&xp3,&yp3);
		l1=xp1-xp0;
		r1=yp1-yp0;
		l2=xp3-xp2;
		r2=yp3-yp2;
		sum=l1*r2-l2*r1;
		if(sum==0)printf("2\n");
		else{
			sum=l1*l2+r1*r2;
			if(sum==0)printf("1\n");
			else printf("0\n");
		}
	}
}


Measured memory_bytes: 3252
#![allow(non_snake_case, unused_mut)]
use std::collections::HashMap;
fn main() {
    proconio::input! {
        N:i64,
        A:[i64;N],
        Q:i64,
        BC:[(i64,i64);Q]
    }
    let mut nums = HashMap::new();
    for &a in A.iter() {
        *nums.entry(a).or_insert(0) += 1i64;
    }
    let mut ans = 0;
    for (&k, &v) in nums.iter() {
        ans += k * v;
    }
    // これは通らない。
    //    for &(b, c) in BC.iter() {
    //        if let Some(v) = nums.get(&b) {
    //            *nums.entry(c).or_insert(0) += 1;
    //            ans = ans + (c - b) * v;
    //            *nums.entry(b).or_insert(0) = 0;
    //        }
    //        println!("{}", ans);
    //    }

    for &(b, c) in BC.iter() {
        let v = nums.remove(&b).unwrap_or(0);
        ans = ans + (c - b) * v;
        *nums.entry(c).or_insert(0) += v;
        println!("{}", ans);
    }
}


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

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

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

    int s[n];
    REP(i, n) {
        char input;
        cin >> input;
        if (input == '#') {
            s[i] = 1;
        }
        else {
            s[i] = 0;
        }
    }

    int b_cnt = 0;
    int w_cnt = n - accumulate(s, s+n, 0);
    int min_cnt = w_cnt + b_cnt;
    REP(i, n) {
        if(s[i] == 1) {
            b_cnt++;
        }
        else {
            w_cnt--;
        }

        if (w_cnt + b_cnt < min_cnt) {
            min_cnt = w_cnt + b_cnt;
        }
    }
    cout << min_cnt << endl;

    return 0;
}


Measured memory_bytes: 1152
N = int(input())
*A, = map(int, input().split())
flag = 1
i = 0
count = 0
while i < N-1:
    for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            tmp = A[j]
            A[j] = A[j-1]
            A[j-1] = tmp
            count += 1
    i += 1
        
print(*A)
print(count)


Measured memory_bytes: 5600
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "No";
        for(int i = 0; i < 2; i++){
            if(s.charAt(i) == s.charAt(i + 1) && s.charAt(i + 2) == s.charAt(i)){
                ans = "Yes";
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23508
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#define SQR(X) ( (X) * (X) )

long double minkosu(long sa[],long n,long double p)
{
   long i,j;
   long double tmp=0;
   if(p == 100) {
      for(i=0;i<n;i++) {
         if(tmp< fabsl( sa[i] ) )
            tmp = fabsl(sa[i]);
      }
      return tmp;
   }

   else {
      for(i=0;i<n;i++)
         tmp += powl( fabsl( sa[i] ) ,p);


      return powl(tmp,1/p);
   }
}


int main()
{
   long i,j,k,l;
   long n;
   long x[100];
   long y[100];
   long sa[100];

   cin >> n;

   for(i=0;i<n;i++)
      cin >> x[i];

   for(i=0;i<n;i++) {
      cin >> y[i];
      sa[i] = x[i] - y[i];
   }

   printf("%llf\n",minkosu(sa,n,1));
   printf("%llf\n",minkosu(sa,n,2));
   printf("%llf\n",minkosu(sa,n,3));
   printf("%llf\n",minkosu(sa,n,100));

   return 0;
}

Measured memory_bytes: 1216
from collections import deque
n, u, v = map(int,input().split())
tree = [[] for _ in range(n+1)]
for _i in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)


def solve(x):
    visit = [-1 for _ in range(n+1)]
    visit[x] = 0
    q = deque([x])
    while q:
        p = q.popleft()
        for i in tree[p]:
            if visit[i] < 0:
                visit[i] = visit[p]+1
                q.append(i)
    return visit

visit_a = solve(v)
visit_t = solve(u)

x, y = [], []
for i in range(1, n+1):
    if visit_a[i] >= visit_t[i]:
        x.append(visit_a[i])
        y.append(visit_t[i])
p = x.index(max(x))

print(x[p]-1)

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.parallelSort(A);
		if (A[0] == A[N - 1] && A[0] == 0) {
			System.out.println("Yes");
			return;
		}else if (A[0]==0&&A[N/2-1]==A[0]&&A[N/2-1]!=A[N/2]&&A[N/2]==A[N-1]) {
			System.out.println("Yes");
		} else if (A[0] == A[N / 3 - 1] && A[N / 3 - 1] != A[N / 3] && A[N / 3] == A[N / 3 * 2 - 1]
				&& A[N / 3 * 2 - 1] != A[N / 3 * 2]&&A[N / 3 * 2]==A[N -1]) {
			if (N % 3 != 0) {
				System.out.println("No");
				return;
			} else {
				if ((A[0]^A[N/3])==A[N/3*2]) {
					System.out.println("Yes");
					return;
				} else {
					System.out.println("No");
					return;
				}
			}
		}  else if (A[N / 3 - 1] ==0&& A[N / 3 - 1] != A[N / 3]&&A[N/3]==A[N-1] ) {
			if (N % 3 != 0) {
				System.out.println("No");
				return;
			} else {
				System.out.println("Yes");
			}
		} else {
			System.out.println("No");
			return;
		}
	}
}

Measured memory_bytes: 59732
#include <stdio.h>
#define N 200000
int main()
{
  int r[N],ri,rj[N],n,i,j,ie=0,je=0,imax,max;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&r[i]);
  for(i=0;i<n;i++)
    {
      if(i==0)
	{
	  ri=r[i];
	  ie++;
	  for(j=ie;j<n;j++)
	    {
	      imax=r[j]-ri;
	      if(j==ie)
		max=imax;
	      if(imax>max)
		max=imax;	     
	    }
	  continue;
	}
      if(i>0&&ri<=r[i])
	{
	  ie++;
	  continue;
	}
      if(i>0&&ri>r[i])
	{
	  ri=r[i];
	  ie++;
	  for(j=ie;j<n;j++)
	    {
	      imax=r[j]-ri;
	      if(imax>max)
		max=imax;	     
	    }
	  continue;
	}
    }
  printf("%d",max);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2560
#include <stdio.h>
int main()
{
    int a,b;
    long long int  c=1000000000000000000,d=1;
    scanf("%d",&a);
    long long int op[a];
    for(b=0;b<a;b++)
    {scanf("%lld",&op[b]); if(op[b]==0) d=0;}
    for(b=0;b<a;b++)
    {
        if(op[b]==0) {d=0; break;}
        else if(c/op[b]<d)  {d=-1; break;}
        else d*=op[b];
    }
    printf("%lld",d);

    return 0;
}


Measured memory_bytes: 2920
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

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

  int NMdiff = abs(n - m);
  if (NMdiff != 0 && NMdiff != 1) {
    cout << 0 << endl;
    return 0;
  }

  ll np = 1, mp = 1;
  ll mod = 1000000007;

  for (int i = 1; i <= n; i++) {
    np = np * i % mod;
  }
  for (int i = 1; i <= m; i++) {
    mp = mp * i % mod;
  }

  if (NMdiff == 1) {
    cout << np * mp % mod << endl;
    return 0;
  }
  if (NMdiff == 0) {
    cout << np * mp * 2 % mod << endl;
    return 0;
  }

}


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

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;
static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s; cin >> s;
	int N = s.size();
	LL ans= 0;
	LL ca = 0;
	for(int i=0; i<N; i++){
		if(s[i] == 'A'){
			ca++;
		}
		else if(s[i] == 'C'){
			ca = 0;
		}
		else if(s[i] == 'B'){
			if(i+1<N && s[i+1] == 'C'){
				ans += ca;
				i++;
			}
			else if(i+1<N && s[i+1] == 'B'){
				ca = 0;
				i++;
			}
			else if(i+1<N && s[i+1] == 'A'){
				ca = 1;
				i++;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3844