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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    vector<int> ans = {};
    int cnt = 0;
    while (A.size() > 1) {
        int Amax = A[A.size() - 1];
        int Amin = A[0];
        A.erase(A.begin());
        A.erase(A.begin() + A.size() - 1);

        if (cnt % 2 == 0) {
            ans.insert(ans.begin(), Amin);
            ans.push_back(Amax);
            cnt++;
        }
        else {
            ans.insert(ans.begin(), Amax);
            ans.push_back(Amin);
            cnt++;
        }
    }

    long long res = 0;
    if (A.size() == 1) {
        res = max(abs(ans[0] - A[0]), abs(ans[ans.size() - 1] - A[0]));
    }

    for (int i = 1; i < ans.size(); i++) {
        res += abs(ans[i] - ans[i - 1]);
    }

  	cout << res << endl;
}

Measured memory_bytes: 1276
#include<stdio.h>

int main(void)
{
    int a,b;

    scanf("%d%d", &a, &b);

    if ((a+b)%2) {
        printf("%d\n", ((a+b)/2)+1);
    }
    else {
        printf("%d\n", (a+b)/2);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a) ((a)>0?(a):(-(a)))

using namespace std;

int main(){
	llong X,K,D;
	cin >> X >> K >> D;
	if( X < 0 ) X = -X;
	
	llong k = X/D;
	llong ans;
	if( k > K ) ans = X - K*D;
	else{
		ans = X - k*D;
		if( (K-k)%2 != 0 ) ans = D-ans;
	}
	cout << ans; 
	
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	ll a[1002] = {};
	int n;
	cin >> n;
	rep1(i,n){
		int x = i;
		for(int j = 2 ; j*j <= x ; j ++){
			while(x%j==0){
				x /= j;
				a[j] ++;
			}
		}
		if(x > 1)a[x] ++;
	}
	
	ll ret = 1;
	rep(i,1002){
		ret *= a[i]+1;
		ret %= 1000000007;
	}
	cout << ret << endl;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push_back
#define ITR ::iterator


#define MOD 1000000009LL
#define EPS 1e-8


const int MAX_N = 1 << 18;

int n, ar[MAX_N], dat[MAX_N * 2 - 1];
int dummy;

void init(int n_){
	n = 1;
	while(n < n_) n *= 2;
	for(int i = 0; i < n; ++i){
		dat[i + n - 1] = i;
	}
	for(int i = n - 2; i >= 0; --i){
		int vl = dat[i * 2 + 1], vr = dat[i * 2 + 2];
		dat[i] = ar[vl] > ar[vr] ? vr : vl;
	}
	dummy = n - 2;
}

int query(int a, int b, int k = 0, int l = 0, int r = n){
	if(r <= a || b <= l) return dummy;
	if(a <= l && r <= b) return dat[k];
	int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
	int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
	if(ar[vl] > ar[vr]) return vr;
	return vl;
}


int ans;
void solve(int l, int r){
	stack<pii> st;
	st.push(pii(l, r));
	while(!st.empty()){
		l = st.top().first;
		r = st.top().second;
		st.pop();

		int x = query(l, r);
		if(ar[x] != INT_MAX){
			++ans;
			while(1){
				int y = query(l, r);
				if(ar[x] != ar[y]){
					break;
				}
				st.push(pii(l, y));
				l = y + 1;
			}
			st.push(pii(l, r));
		}
	}
}

int main(){
	for(int i = 0; i < MAX_N; ++i){
		ar[i] = INT_MAX;
	}

	int N;
	scanf("%d", &N);
	for(int i = 0; i < N; ++i){
		scanf("%d", &ar[i]);
	}
	init(N + 10);
	solve(0, N);
	printf("%d\n", ans);
}

Measured memory_bytes: 5868
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> X;
    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        X.push_back(t);
    }

    auto S = X;
    std::sort(std::begin(S), std::end(S));

    for (int64_t i = 0; i < N; ++i) {
        if (X[i] < S[N/2]) {
            std::cout << S[N/2] << std::endl;
        }
        else {
            std::cout << S[N/2 - 1] << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5488
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rrep(i,n) for(ll i=(n)-1;i>=0;--i)
#define rep1(i,n) for(ll i=1;i<=(n);++i)
#define rrep1(i,n) for(ll i=(n);i>=1;--i)
#define fr first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

vector<ll> A;
vector<ll> B;
ll ans;
ll N;
ll a[200000];
ll b[200000];
ll ub,lb,mid,z,res;
void calc(ll n){
	res=0;

	A.clear();
	B.clear();
	ll d=(1<<(n+1))-1;
	rep(i,N){
		A.pb(a[i]&d);
		B.pb(b[i]&d);
	}
	sort(B.begin(),B.end());
	
	d=1<<n;
	rep(i,N){//A[i]とB[0]~B[N-1]について
		ll x=A[i];
		ll m= (d&A[i])>>n;
		ub=N;
		lb=-1;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			if(B[mid]&d) ub=mid;
			else lb=mid;
		}
		z=ub;
		ub=z;
		lb=-1;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			if( ((x+B[mid])&d) ^ (x & d) ) ub=mid;
			else lb=mid;
		}
		if(m){
			res+= lb+1;
		}
		else{
			res+= z-ub;
		}
		
		ub=N;
		lb=z-1;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			if( ((x+B[mid])&d) ^ (x & d) ) lb=mid;
			else ub=mid;
		}
		if(m){
			res+= N-ub;
		}
		else{
			res+= ub-z;
		}
	}
//	cout<<res<<endl;

	res%=2LL;
	ans+= (res<<n);
}

int main()
{
	ans=0;
	cin>>N;
	rep(i,N) cin>>a[i];
	rep(i,N) cin>>b[i];
	rep(i,30) calc(i);
	cout<<ans<<endl;
}

Measured memory_bytes: 6756
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int n, E[N], W[N], S[N];
ll H[N];
vector<int> G[N];

void DFS(int v, int p = 0) {
	S[v] = 1;
	for (int e : G[v]) if (e != p) {
		int u = E[e] ^ v, w = W[e];
		H[u] = H[v] + w, DFS(u, e), S[v] += S[u];
	}
}
int GetCentroid(int v, int p = 0) {
	for (int e : G[v]) if (e != p) {
		int u = E[e] ^ v;
		if (S[u] * 2 > n) return GetCentroid(u, e);
	}
	return v;
}

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	cin >> n;
	for (int i = 1; i < n; i++) {
		int v, u; cin >> v >> u >> W[i];
		G[v].push_back(i), G[u].push_back(i);
		E[i] = v ^ u;
	}
	DFS(1);
	ll ans = 0;
	int c = GetCentroid(1), mn = INF;
	H[c] = 0, DFS(c);
	for (int i = 1; i <= n; i++) ans += H[i] * 2, debug(H[i]);;
	for (int e : G[c]) {
		int u = E[e] ^ c, w = W[e];
		if (n % 2 == 0 && S[u] * 2 == n) die(ans - w);
		mn = min(mn, w);
	}
	cout << ans - mn << endl;
	

	return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long h,w,n,temp,count=0,sum=0;
    cin>>h>>w>>n;
    if(h>w)
    {
     temp=h;
     h=w;
     w=temp;
    }
    while(sum<n)
    {
        sum=sum+w;
        count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	ll n; cin >> n;
	std::vector<ll> A(n+1);
    std::vector<ll> B(n);
	for (int i = 0; i < n+1; ++i) cin >> A[i];
	for (int i = 0; i < n  ; ++i) cin >> B[i];

	ll Ans = 0;

	for (int i = 0; i < n; ++i)
	{
		if (B[i] >= A[i] + A[i+1]) {
			Ans += A[i] + A[i+1];
			A[i]   = 0;
			A[i+1] = 0;
		}else if(A[i] <= B[i] && B[i] <= A[i] + A[i+1]){
			Ans += B[i];
			
			A[i+1] = A[i] + A[i+1] - B[i];
            A[i]   = 0;
		}else{
			Ans += B[i];
			A[i] = A[i] - B[i];
		}
	}

	cout << Ans << endl;
    
   



}

Measured memory_bytes: 1792
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	int ans = 0, n, d, x, y; cin >> n >> d;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		if ((x * x + y * y) <= d * d) ans++;
	}
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


void solve()
{
 string S; cin >> S;
 int dist_even = 0; 
 int dist_odd  = 0;
 char tbl[2] = {'0', '1'};

 REP0(i, S.length())
 {
     dist_even += (S[i] == tbl[i%2]) ? 0 : 1;
     dist_odd  += (S[i] == tbl[1-i%2]) ? 0 : 1;
 }
 cout << min(dist_even, dist_odd) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 512
n, q = ARGF.gets.split.map(&:to_i)

s = ARGF.gets.chomp
t = (0..n).map { 0 }
n.times { |i| t[i+1] = t[i] + (s[i,2] == 'AC' ? 1 : 0) }

q.times do
  l, r = ARGF.gets.split.map(&:to_i)
  puts t[r-1] - t[l-1]
end


Measured memory_bytes: 3452
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;





int main(void){

    

    char c;
    cin >>c;
    string ans;


    int t = c-'A';
    if(t>=0&&t<=25) ans = 'A';
    else ans = 'a';


    cout<<ans;


    return 0;
}

Measured memory_bytes: 3588
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(k, t) = in.readLine().split("\\s+").map(_.toInt)
    val as = in.readLine().split("\\s+").map(_.toInt)

    val m = as.max

    out.println(
      Math.max((m - 1) - (k - m), 0)
    )

    out.flush()
  }
}

Measured memory_bytes: 27332
#include <stdio.h>

void BubSort(int x[ ], int n)
{
    int i, j, temp;

    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (x[j - 1] > x[j]) {  /* ??????????´????????????§????????£?????? */
                temp = x[j];        /* ???????????? */
                x[j] = x[j - 1];
                x[j - 1]= temp;
            }
        }	
    }
}

int main(void)
{
	int hill[10];
	int i;
	
	for ( i = 0; i < 10; i++){
		scanf("%d", &hill[i]);
	}
	
	BubSort(hill, 10);
	
	printf("%d\n%d\n%d\n", hill[9], hill[8], hill[7]);
	
	return (0);
}

Measured memory_bytes: 1784
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>

using namespace std;

int main(void)
{
    long long N;
    set<string> st;
    cin >> N;
    for (long long i = 0; i < N; ++i)
    {
        string tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    cout << st.size();
}


Measured memory_bytes: 19160
N = int(input())
a = list(map(int, input().split()))
D = []
for i in range(N):
    D.append((a[i], i))
D.append((0, -1))
D.sort(reverse=True)
ans = [0] * N
mi = float('inf')
for i in range(N):
    mi = min(mi, D[i][1])
    ans[mi] += (D[i][0] - D[i + 1][0]) * (i + 1)

for i in ans:
    print(i)

Measured memory_bytes: 69092
#include<iostream>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;
int N,ans1=1,ans2=1;
int b=0;
long long A[100000];
int main(){
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	for(int i=1;i<N;++i){
		if(b==0&&A[i-1]<A[i])b=1;
		if(b==0&&A[i-1]>A[i])b=2;
		if(b==1&&A[i-1]>A[i]){
			++ans1;
			b=0;
		}
		if(b==2&&A[i-1]<A[i]){
			++ans1;
			b=0;
		}
	}
	cout<<ans1<<endl;
	return 0;
}


Measured memory_bytes: 1024
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, M, K := nextInt(), nextInt(), nextInt()
	An := make([]int, N+1)
	Bm := make([]int, M+1)
	CsumA := make([]uint, N+1)
	CsumB := make([]uint, M+1)
	// var sum uint
	var ans int
	for i := 0; i < N; i++ {
		An[i] = nextInt()
		if i > 0 {
			CsumA[i] = CsumA[i-1] + uint(An[i-1])
		}
	}
	CsumA[N] = CsumA[N-1] + uint(An[N-1])
	for i := 0; i < M; i++ {
		Bm[i] = nextInt()
		if i > 0 {
			CsumB[i] = CsumB[i-1] + uint(Bm[i-1])
		}
	}
	if An[0] > K && Bm[0] > K {
		fmt.Println(0)
		return
	}
	CsumB[M] = CsumB[M-1] + uint(Bm[M-1])
	// fmt.Println(CsumA, CsumB)
	j := M
	for i := 0; i <= N; i++ {
		if CsumA[i] > uint(K) {
			break
		}

		for CsumB[j] > uint(K)-CsumA[i] {
			j--
		}
		ans = MaxOf(ans, i+j)
	}
	fmt.Println(ans)
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 15076
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;


int main() {
    int N;
    cin >> N;
    ll sum = 0;
    for (int i=1;i<=N;i++){
        if (i%5 != 0 && i%3 != 0) sum+=i;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
n = int(input())
max_pp = -2 * 10**10
min_pp = 2 * 10**10
max_pn = -2 * 10**10
min_pn = 2 * 10**10

for i in range(n):
  x, y = map(int, input().split())
  max_pp = max(max_pp, x + y)
  min_pp = min(min_pp, x + y)
  max_pn = max(max_pn, x - y)
  min_pn = min(min_pn, x - y)
print(max(max_pp - min_pp, max_pn - min_pn))

Measured memory_bytes: 68396
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	static ll n,a[200010],b,ac[200010],ans=0;
	cin>>n;
	REP(i,n){
		cin>>a[i];
		ac[i]=a[i]-(i+1);
	}
	sort(ac,ac+n);
	b=ac[n/2];
	DEB(b)END
	REP(i,n){
		ans+=abs(a[i]-(b+(i+1)));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<Integer,List<Integer>> tree = new HashMap<>();
		for(int i=0;i<n-1;i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			if(tree.containsKey(a)) tree.get(a).add(b);
			else {
				List<Integer> list = new ArrayList<>();
				list.add(b);
				tree.put(a, list);
			}
			if(tree.containsKey(b)) tree.get(b).add(a);
			else {
				List<Integer> list = new ArrayList<>();
				list.add(a);
				tree.put(b, list);
			}
		}
		in.close();
		int[] board = new int[n+1];
		board[1] = 1;
		board[n] = -1;
		Queue<Integer> que = new ArrayDeque<>();
		que.add(1);
		que.add(n);
		while(!que.isEmpty()) {
			int now = que.poll();
			for(int next:tree.get(now)) {
				if(board[next]==0) {
					board[next] = board[now];
					que.add(next);
				}
			}
		}
		int sum = 0;
		for(int i=1;i<=n;i++) {
			sum += board[i];
		}
		System.out.println(sum>0?"Fennec":"Snuke");
	}

}


Measured memory_bytes: 107432
from itertools import product

H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
S_T = [[int(s[w]) for s in S] for w in range(W)]
sumS = sum(map(sum, S_T))
ans = (H - 1) * (W - 1)

if sumS <= K:
    print(0)
else:
    for i in product([True, False], repeat=H-1):
        cnt = sum(i)
        if cnt >= ans:
            continue
        M = [[0]]
        for j, k in enumerate(i):
            if k:
                M.append([])
            M[-1].append(j+1)
        A = [0] * len(M)
        for s_t in S_T:
            for l, m in enumerate(M):
                A[l] += sum(s_t[i] for i in m)
            if any(a > K for a in A):
                cnt += 1
                if cnt >= ans:
                    break
                A = [sum(s_t[i] for i in m) for m in M]
                if any(a > K for a in A):
                    cnt = ans + 1
                    break
        ans = min(cnt, ans)
    print(ans)


Measured memory_bytes: 3188
s = input()
a, b, c, d = (int(s[0]),int(s[1]),int(s[2]),int(s[3]))

def f(idx):
    return "+" if idx==0 else "-"
for i in range(2):
    for j in range(2):
        for k in range(2):
            num = a
            num += b if i == 0 else -b
            num += c if j == 0 else -c
            num += d if k == 0 else -d

            if num == 7:
                result = str(a) + f(i) + str(b) + f(j) + str(c) + f(k) + str(d) + "=7"
                print(result)
                exit() 

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> mp;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        mp[A[i]]++;
    }
    ll ans = 0;
    for (auto p : mp) {
        ans += p.first * p.second;
    }
    int Q;
    cin >> Q;
    for (int z = 0; z < Q; z++) {
        ll B, C;
        cin >> B >> C;
        ll t = mp[B];
        mp[B] = 0;
        mp[C] += t;
        ans += (C-B)*t;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 10124
N = int(input())
H = list(map(int, input().split(' ')))
count = [0 for i in range(len(H))]

for i in range(1, len(H)):
    if H[i] <= H[i - 1]:
        count[i] = count[i - 1] + 1
    else:
        count[i] = 0

#print(count)
#print(H)
print(max(count))

Measured memory_bytes: 68444
#include<iostream>

using namespace std;

int main(void){

	double y,v,t;
	int step;
	while(cin>>v){
		t=y=0;
		step=0;
		t=v/(9.8);
		y=4.9*t*t;
		step=(int)((y+5)/5)+1;

		printf("%d\n",step);
	}
}

Measured memory_bytes: 0
def main():
    MAX = 10**9

    N, K, S = tuple(int(i) for i in input().split())

    if S == MAX:
        ans = [S - 1 for _ in range(N)]
        for i in range(N):
            if i < K:
                ans[i] = S

        print(" ".join([str(i) for i in ans]))
    else:
        ans = [S + 1 for _ in range(N)]
        for i in range(N):
            if i < K:
                ans[i] = S

        print(" ".join([str(i) for i in ans]))


if __name__ == '__main__':
    main()


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

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

    int score[101] = {};
    map<int,int> res, grade;

    int a, b, c, d;
    for(int i = 0; i < n*(n-1)/2; i++){
        cin >> a >> b >> c >> d;
        a--; b--;
        if(c == d){
            score[a]++;
            score[b]++;
        }else if(c < d){
            score[b] += 3;
        }else if(c > d){
            score[a] += 3;
        }
    }

    for(int i = 0; i < n; i++)  res[score[i]]++;

    int now = 1;
    for(auto x = res.rbegin(); x != res.rend(); x++){
        grade[(*x).first] = now;
        now += (*x).second;
    }

    for(int i = 0; i < n; i++)  cout << grade[score[i]] << endl;

    return 0;
}


Measured memory_bytes: 3084
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

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

    int blue =0;
    int red =0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            red++;
        }else{
            blue++;
        }
    }

    if(red > blue){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
    int n;cin>>n;
    int a[n];REP(i,n)cin>>a[i];
    int now=1;
    int ans=0;
    REP(i,n){
        if(a[i]==now){
            now++;
            ans++;
        }
    }
    cout<<((ans==0)?-1:(n-ans))<<endl;
}

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



Measured memory_bytes: 1024
#include<iostream>
using namespace std;
 
int main() {
    char c;
    while (1) {
        cin.get(c);
        if (c == '\n')break;
        else if ('A' <= c && c <= 'Z')c += 'a' - 'A';
        else if ('a' <= c && c <= 'z')c -= 'a' - 'A';
        cout.put(c);
    }
    cout << endl;
        return 0;
}
     

Measured memory_bytes: 3096
import sys

readline = sys.stdin.readline
writelines = sys.stdout.writelines  
N = int(readline())

depth = [0]*N
PR = [-1]*N
G = [None]*N

for i in range(N):
    i, _, *cs, = map(int, readline().split())
    G[i] = cs
    for v in G[i]:
        PR[v] = i

def dfs(v, d):
    depth[v] = d
    for w in G[v]:
        dfs(w, d+1)

dfs(PR.index(-1), 0)
writelines(["node %d: parent = %d, depth = %d, %s, %s\n" % (i, PR[i], depth[i], ('root' if PR[i] == -1 else 'leaf' if len(G[i]) == 0 else 'internal node'), G[i]) for i in range(N)])




Measured memory_bytes: 33448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String S = in.next();
			int year = Integer.parseInt(S.substring(0, 4));
			int month = Integer.parseInt(S.substring(5, 7));
			int day = Integer.parseInt(S.substring(8, 10));
			String ans = "";
			if(year < 2020 && month < 5 && day < 31 ) {
				ans = "Heisei";
			} else {
				ans = "TBD";
			}
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

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

	}
}


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

void solve(long long N, long long M, vector<long long> a, vector<long long> b){
	vector<set<int>> e(N + 1);
	for(int i = 0; i < M; ++i) {
		e[a[i]].insert(b[i]);
		e[b[i]].insert(a[i]);
	}

	for(int i = 2; i < N; ++i) {
		if(e[1].find(i) != e[1].end() && e[N].find(i) != e[N].end()) {
			cout << "POSSIBLE" << endl;
			return;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

int main(){	
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> a(M-1+1);
	vector<long long> b(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&a[i]);
		scanf("%lld",&b[i]);
	}
	solve(N, M, a, b);
	return 0;
}



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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    vvll a(3, vll(3));
    vvll v(3, vll(3, 0));
    ll n, b;
    cin >> a >> n;
    REP(i,n){
        cin >> b;
        REP(j,3) REP(h,3) if (a[j][h]==b) v[j][h]=1;
    }
    REP(i,3){
        if(v[i][0] * v[i][1] * v[i][2]) {cout << "Yes" << endl; return 0;}
        if(v[0][i] * v[1][i] * v[2][i]) {cout << "Yes" << endl; return 0;}
    }
    if(v[0][0] * v[1][1] * v[2][2]) {cout << "Yes" << endl; return 0;}
    if(v[0][2] * v[1][1] * v[2][0]) {cout << "Yes" << endl; return 0;}
    cout << "No" << endl; return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String blueCard[] = new String[n];
		for (int i = 0; i < n; i++) {
			blueCard[i] = sc.next();
		}

		int m = sc.nextInt();
		String redCard[] = new String[m];
		for (int i = 0; i < m; i++) {
			redCard[i] = sc.next();
		}
		System.out.println(getMax(blueCard, n, redCard, m));
	}

	public static int getMax(String blueCard[], int n, String redCard[], int m) {

		int blueCardCount[] = new int[n];

		for (int i = 0; i < n; i++) {
			blueCardCount[i] = 1;
		}
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				if (blueCard[i].equals(blueCard[j]))
					blueCardCount[i]++;
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (blueCard[i].equals(redCard[j]))
					blueCardCount[i]--;
			}
		}

		int max = 0;
		for (int i = 0; i < n; i++) {
			if (blueCardCount[i] > max) {
				max = blueCardCount[i];
			}
		}

		return max;
	}

}


Measured memory_bytes: 20820
--{-# LANGUAGE OverloadedStrings #-}
--{-# LANGUAGE OverloadedLists   #-}
{-# LANGUAGE BangPatterns      #-} --引数に!
{-# LANGUAGE MultiWayIf        #-}
{-# LANGUAGE TupleSections     #-}

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
--import Data.Matrix.Unboxed
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Data.Graph
--import Data.Vector as V　--変数衝突
import qualified Data.ByteString.Lazy.Char8 as B
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Control.Monad.State
import Control.Monad.ST
import Debug.Trace

type T = UArray Int Int

solve :: Int -> Int -> Int -> Int -> [Int] -> [Int] -> [Int] -> [Int]
solve x y z k as' bs' cs' = do
  let as = (sortOn (0-) as')
      bs = (sortOn (0-) bs')
      cs = (sortOn (0-) cs')
      sub l1 l2 = sortOn (0-) [x+y | x <- l1, y <- l2]
    in take k $ sub cs $ take k $ sub as bs


readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

main0 :: B.ByteString -> [Int]
main0 cont =
   let remLines0 = map (map readBInt . B.words) (B.lines cont)
       [x,y,z,k]:remLines1 = remLines0
       as:remLines2 = remLines1
       bs:remLines3 = remLines2
       cs:remLines4 = remLines3
   in solve x y z k as bs cs

main :: IO ()
main = (flip forM_ $ \i -> print i) . main0 =<< B.getContents

mod' :: Int -> Int
mod' n = if n < 1000000007 then n else mod n 1000000007


Measured memory_bytes: 540028
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000009
#define pb push_back
#define endl '\n'
#define tez_chal ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)



const ll INF=1e9+7;

int solve()
{
 
  ll n,k;cin>>n>>k;
  vector<ll>v(n),dp(n,INF);
  for(auto &i:v) cin>>i;
  dp[0]=0;
  for(ll i=1;i<n;i++){
  	  for(ll j=1;j<=k;j++){	
  		if(i-j>=0){
  			dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
  		}
  	}
  }
  cout<<dp[n-1]<<endl;
 



return 0;
}


 








int main()
{  
    tez_chal;     ll t=1;  //cin>>t;
    
    while(t--) solve();

    // ll testcase=1;
    // while(t--){
    // 	cout<<"Case #"<<testcase++<<": ";
    // 	solve();
    // }

    return 0;
}




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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int h,w,k;
	cin>>h>>w>>k;
	vector<string> s(h);
	rep(i,h)cin>>s[i];

	vector<vector<int>> a(h,vector<int>(w,0));

	int cnt=1;

	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#'){
				a[i][j] = cnt;
				cnt++;
			}
		}
	}

	// cnt=1;
	// rep(i,h){
	// 	rep(j,w){
	// 		if(a[i][j]==cnt){
	// 			int l=0;
	// 			while(a[i][l]>0)l++;
	// 			while(l<w&&a[i][l]==0){
	// 				a[i][l]=a[i][j],l++;
	// 				if(a[i][l]>0 && a[i][l]!=a[i][j]){
	// 					// cout<<a[i][l]<<endl;
	// 					break;
	// 				}
	// 			}
	// 			cnt++;
	// 		}
	// 	}

		// rep(i,h){
		// rep(j,w){
		// 	cout<<a[i][j]<<" ";
		// }
		// cout<<endl;
		// }
		// cout<<endl;
	// }

	// rep(i,h){
	// 	rep(j,w){
	// 		cout<<a[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	rep(i,h){
		rep(j,w-1){
			if(a[i][j+1]==0)a[i][j+1] = a[i][j];
		}
	}
	rep(i,h){
		repr(j,w-1,1)if(a[i][j-1]==0)a[i][j-1]=a[i][j];
	}

	rep(i,h-1){
		rep(j,w){
			if(a[i+1][j]==0)a[i+1][j]=a[i][j];
		}
	}
	repr(i,h-1,1){
		rep(j,w){
			if(a[i-1][j]==0)a[i-1][j]=a[i][j];
		}
	}

	rep(i,h){
		rep(j,w){
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}

	
	return 0;
}

Measured memory_bytes: 1280
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

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

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 1e9 + 7;
const double PI = acos(-1);

int main() {
	IOS;
	int s, w; cin >> s >> w;
	if (w >= s) cout << "unsafe";
	else cout << "safe";
}

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

int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n,n)
	{
		string s;
		bool l=0,r=0,u=0;
		int ans=0;
		for (int i = 0; i < n; ++i)
		{
			cin>>s;
			if(s=="lu") l=1;
			else if(s=="ld") l=0;
			else if(s=="ru") r=1;
			else r=0;
			if(u&&!l&&!r) ++ans,u=0;
			else if(!u&&l&&r) ++ans,u=1;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3152
#include <stdio.h>
#include <stdlib.h>


int main () {
    int n, w, i, j, itmv, itmw, v1, v2;
    int value[100], weight[100];
    int **wv, *wv_data;

    scanf("%d %d", &n, &w);
    for (i=0; i<n; i++) {
        scanf("%d %d", &value[i], &weight[i]);
    }

    wv_data = (int*)malloc(sizeof(int) * (n+1) * (w+1));
    wv = (int**)malloc(sizeof(int*) * (n+1));
    for (i = 0; i <= n; i++) {
        wv[i] = &(wv_data[i*(w+1)]);
    }

    for (i=0; i <= w; i++) {
        wv[0][i] = 0;
    }
    for (i=1; i <= n; i++) {
        wv[i][0] = 0;
    }

    for (i = 1; i <= n; i++) {
        itmv = value[i-1];
        itmw = weight[i-1];
        for (j = 1; j <= w; j++) {
            if (j >= itmw) {
                v1 = wv[i][j-itmw] + itmv;
                v2 = wv[i-1][j];
                wv[i][j] = v1 > v2 ? v1 : v2;
            }
            else {
                wv[i][j] = wv[i-1][j];
            }
        }
    }
    printf("%d\n", wv[n][w]);

    free(wv_data);
    free(wv);

    return 0;
}

Measured memory_bytes: 4516
n=gets.to_i
a=1
for i in 0..5 do
  a=10**i if 10**i<n
end
b=n-a
ans=0
while a!=0 do
  ans+=a%10
  a=a/10
end
while b!=0 do
  ans+=b%10
  b=b/10
end
puts(ans)


Measured memory_bytes: 1788
#include <stdio.h>

int		main(void)
{
	int		ABC[3];
	int		count7;
	int		count5;

	count7 = 0;
	count5 = 0;
	scanf("%d %d %d",&ABC[0], &ABC[1], &ABC[2]);
	for (int i = 0; i < 3; i++)
	{
		if (ABC[i] == 7)
			count7++;
		else if (ABC[i] == 5)
			count5++;
	}
	if (count5 == 2 && count7 == 1)
		printf("YES");
	else
		printf("NO");
	return (0);
}


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

int main() {
	string S;
	cin >> S;
	
	if (S.at(0) == S.at(1) && S.at(0) == S.at(2)) {
		cout << "No" << endl;
	}

	else {
		cout << "Yes" << endl;
	}
}

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

int main(){
  int n = 4;
  vector<char > s(n);
  for ( int i = 0; i < n; i++ ) {
    cin >> s.at(i);
  }

  bool ans = false;
  if ( s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2) ) ans = true;
  else if ( s.at(0) == s.at(2) && s.at(1) == s.at(3) && s.at(0) != s.at(1) ) ans = true;
  else if ( s.at(0) == s.at(3) && s.at(1) == s.at(2) && s.at(0) != s.at(1) ) ans = true;

  if ( ans ) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
# 2019/09/15
# AtCoder Beginner Contest 141 - C

# Input
n, k, q = map(int, input().split())
a = [0] * n
for i in range(q):
    wka = int(input())
    a[wka-1] = a[wka-1] + 1

# Output
for i in range(n):
    if k - (q - a[i]) > 0:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)

Measured memory_bytes: 4680
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,double> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

ll dp[55][2];

int main() {
    ll n,k;cin>>n>>k;
    ll a[100010];
    rep(i,n) cin>>a[i];

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

    rep(i,50) {
        rep(j,2) dp[i][j]=-1;
    }

    dp[0][0]=0;

    rep(i,50) {
        int ith_bit = (k >> (50 - i - 1)) & 1;

        ll num_0=0;
        rep(j,n) {
            num_0 += ((a[j] >> (50 - i - 1)) & 1) ^ 0;
            // num_1 += ((a[j] >> (50 - i - 1)) & 1) ^ 1;
        }

        if(dp[i][1] != -1) {
            dp[i+1][1] = max(dp[i+1][1],dp[i][1] + max(num_0,n-num_0) * (1LL<<50-i-1));
        }

        if(dp[i][0] != -1 && ith_bit ==1) {
            dp[i+1][1] = max(dp[i+1][1],dp[i][0] + num_0 * (1LL<<(50-i-1)));
        }

        if(dp[i][0] != -1) {
            if(ith_bit) {
                dp[i+1][0] = max(dp[i+1][0],dp[i][0] + (n - num_0) * (1LL<<(50-i-1))); 
            } else {
                dp[i+1][0] = max(dp[i+1][0],dp[i][0] + num_0 * (1LL<<(50-i-1)));
            }
        }

    }

    cout << max(dp[50][0],dp[50][1]) << endl;
}

Measured memory_bytes: 4352
// #define debug
#ifdef debug
#include <time.h>
#include "/home/majiao/mb.h"
#endif


#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#define MAXN 100005
#include <map>
#include <unordered_set>
#define IS_PRIME(x) (!vis[x])
#define ll long long int

using namespace std;

int prime[MAXN], n, pn, vis[MAXN];
int sum[MAXN]; //统计符合要求的前缀和

void get_prime() {
	vis[0] = vis[1] = true;
	int MN = MAXN- 1;
	for(int i=2; i<MN; i++) {
		if(!vis[i]) {
			prime[pn++] = i;
		}
		if(i!=2 && IS_PRIME(i) && IS_PRIME((i+1)>>1))
		   sum[i] = sum[i-1] + 1;
		else sum[i] = sum[i-1];

		for(int k=0; k<pn && i*prime[k]<MN; k++) {
			vis[i*prime[k]] = true;
			if(i%prime[k] == 0) break;
		}
	}
}

int main() {
#ifdef debug
	freopen("test", "r", stdin);
	clock_t stime = clock();
#endif
	get_prime();
//	forarr(prime, 0, 13);
//	forarr(sum, 0, 7);
	int Q, lef, rig;
	scanf("%d ", &Q);
	while(Q--) {
		scanf("%d %d ", &lef, &rig);
		printf("%d\n", sum[rig]-sum[lef-1]);
	}




#ifdef debug
	clock_t etime = clock();
	printf("rum time: %lf 秒\n",(double) (etime-stime)/CLOCKS_PER_SEC);
#endif 
	return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <utility>

using namespace std;

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

int main() {
	ll n;
	vector<pair<ll, bool> > b;
	vector<P> e, o;
	bool use[1000]{};
	cin >> n;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		b.push_back({ a, false });
		if (i % 2 == 0)e.push_back({ a, i });
		else o.push_back({ a, i });
	}
	sort(e.begin(), e.end(), greater<P>());
	sort(o.begin(), o.end(), greater<P>());
	ll esum = e[0].first, osum = o[0].first, s = 1, t = 1;
	while (s < e.size() && e[s].first > 0) {
		esum += e[s].first;
		s++;
	}
	while (t < o.size() && o[t].first > 0) {
		osum += o[t].first;
		t++;
	}
	if (esum > osum) {
		for (int i = 0; i < s; i++)b[e[i].second].second = true;
	}
	else for (int i = 0; i < t; i++)b[o[i].second].second = true;
	vector<ll> ans;
	while (b.size() > 1) {
		ll m = b.size();
		if (!(b.end()-1)->second) {
			ans.push_back(m);
			b.pop_back();
			continue;
		}
		if (!b.begin()->second) {
			ans.push_back(1);
			b.erase(b.begin());
			continue;
		}
		if ((b.end() - 3)->second) {
			ans.push_back(m - 1);
			b[m - 3].first += b[m - 1].first;
			b.pop_back();
			b.pop_back();
			continue;
		}
		ans.push_back(m - 2);
		b.erase(b.end() - 3, b.end()-1);
	}
	cout << max(esum, osum) << endl << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
	return 0;
}
/*
偶数番目、奇数番目同士でしか足されることがないのでそれぞれの総和の大きいほうが最大値
*/

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

def stamina(x, p):
    return (x-p) ** 2
# x[i] - p^2
l = []
for i in range(min(X),max(X)+1):
    ans = 0
    for j in X:
        ans += stamina(j, i)
    l.append(ans)

print(min(l))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N, M; cin >> N >> M;
	ll a[51], b[51], c[51], d[51];
	repe(i, 1, N) {
		cin >> a[i] >> b[i];
	}
	repe(i, 1, M) {
		cin >> c[i] >> d[i];
	}
	repe(i, 1, N) {
		ll minV = 1 << 30;

		ll cp = 0;
		repe(j, 1, M) {
			ll e = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (minV > e) {
				minV = e;
				cp = j;
			}
		}
		cout << cp << endl;
	}

	return 0;
}

Measured memory_bytes: 256