akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

vector<bool> c(1000001, true);

int main()
{
    int n, ans = 0;
    cin>>n;
    VI a(n);
    REP(i,n) {
        cin>>a[i];
    }
    SORT(a);

    REP(i,n) {
        //cout<<a[i]<<" "<<c[a[i]]<<endl;
        if (c[a[i]] && !(i != n - 1 && a[i] == a[i+1])) {
            ans++;
        }

        if (i != 0 && a[i] == a[i-1])
            continue;

        int x = 1;
        while (a[i] * x <= a[n-1]) {
            c[a[i] * x] = false;
            //cout<<a[i] * x<<" "<<c[a[i] * x]<<endl;
            x++;
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

int main(){
    string s;
    cin>>s;
    int N,W,E,S;
    N = E = W = S = -1;

    for(int i=0; i<(int)s.size(); i++){
        if(s[i] == 'N') N = i;
        else if(s[i] == 'S') S = i;
        else if(s[i] == 'E') E = i;
        else if(s[i] == 'W') W = i;
    }

    string ans = "Yes";

    if((N != -1 && S == -1) || (N == -1 && S != -1)) ans = "No";
    if((W != -1 && E == -1) || (W == -1 && E != -1)) ans = "No";

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import *
g=lambda a,x,b:a+b if x=='+'else a-b if x=='-'else a*b
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   if g(g(g(a,x,b),y,c),z,d)==10:return f"(({a}{x}{b}){y}{c}){z}{d}"
   if g(g(a,x,b),y,g(c,z,d))==10:return f"({a}{x}{b}){y}({c}{z}{d})"
 return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


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

int main(void){
	int sum=0,num=0,n=0;
	while(true){
		char tmp;
		int a,b;
		cin >> a >> tmp >> b;
		if(cin.eof())
			break;
		sum+=a*b;
		num+=b;
		n++;
	}
	int ave=((double)num/n)+0.5;
	cout << sum << endl << ave << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
#define pb push_back
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
set<int> adj[200002];
bool visited[200002];
ll dfs(int u){
    ll curr = 1;
    visited[u] = 1;
    for(auto v : adj[u]){
        if(!visited[v]){
            curr += dfs(v);
        }
    }
    return curr;
}
int main(){
    #ifndef ONLINE_JUDGE    
    freopen("../../input", "r", stdin);
    freopen("../../output", "w", stdout);
    #else
    // online submission
    #endif

    boost
    int tt = 1;
    // cout << 0 << endl;
    // cin >> tt;
    while(tt--){
        ll n, m;
        cin >> n >> m;
        int x, y;
        ll ans = 0;
        for(int i = 0; i < m; i++){
            cin >> x >> y;
            adj[x].insert(y);
            adj[y].insert(x);
        }
        for(int i = 1; i <= n; i++){
            if(visited[i] == 0){
                ans = max(ans, dfs(i));
            }
        }
        cout << ans;
    }
}


Measured memory_bytes: 41252
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

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

	int ans = 0;
	int max = *max_element(p.begin(), p.end());
	ans = accumulate(p.begin(), p.end(), 0) - max / 2;

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[15];
long long dp[15][3];
int main(int argc, char const *argv[])
{
	cin>>n;
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++)
		cin>>a[i];
	if(a[0]%2==0)
	{
		dp[0][0]=2;
		dp[0][1]=1;
	}
	else
	{
		dp[0][0]=1;
		dp[0][1]=2;
	}
	for(int i=1;i<n;i++)
	{
		if(a[i]%2==0)
		{
			dp[i][1]=dp[i-1][0]+dp[i-1][1]*3LL;
			dp[i][0]=dp[i-1][0]*2;
		}
		else
		{
			dp[i][1]=(dp[i-1][0]*2LL+dp[i-1][1]*3LL);
			dp[i][0]=dp[i-1][0];
		}
	}
	cout<<dp[n-1][1]<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int A, B;

int main()
{
    cin >> A >> B;
    vector<vector<char>> grid(100, vector<char>(100));
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            if (i < 50)
                grid[i][j] = '#';
            else
                grid[i][j] = '.';
        }
    }
    A--, B--;
    for (int i = 0; i < 49 && A > 0; i += 2)
    {
        for (int j = 0; j < 100 && A > 0; j += 2)
        {

            grid[i][j] = '.';
            A--;
        }
    }

    for (int i = 51; i < 100 && B > 0; i += 2)
    {
        for (int j = 0; j < 100 && B > 0; j += 2)
        {
            grid[i][j] = '#';
            B--;
        }
    }
    puts("100 100");
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            cout << grid[i][j];
        }
        cout << "\n";
    }
    
}


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

int main(){
	int n,k,r,s,p;
	string t;
	cin>>n>>k>>r>>s>>p>>t;
	long long total=0;
	string s1="";
	for(int i=0;i<n;i++){
		if(i-k>=0){
			if(t[i-k]==t[i]){
				if(t[i]=='s' && s1[i-k]=='r'){
				 s1=s1+'s';
				 continue;
			     }
				else if(t[i]=='p' && s1[i-k]=='s'){
				  s1=s1+'p';
				 continue;
			     }
				else if(t[i]=='r' && s1[i-k]=='p'){
				 s1=s1+'r';
				 continue;
			    }
			} 
			
		}
		if(t[i]=='s'){
		 total=total+r;
		 s1=s1+'r';
	    }
	    else if(t[i]=='p'){
			total+=s;
			s1=s1+'s';
		}
		else{
			total+=p;
			s1=s1+'p';
		}
	}
	cout<<total;
}
	  
		 


Measured memory_bytes: 932
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    double p[n+1];
    for(int i = 1; i <= n; i++) {
        p[i] = 1.0;
    }

    for(int i = 1; i <= n; i++) {
        if(i >= k) {
            break;
        }

        int score = i;
        while(score < k) {
            score *= 2;
            p[i] /= 2.0;
        }
    }

    double ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += p[i];
    }
    ans /= (double)n;

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

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = 998244353;
const LL N = 2e5+1;

int main() {
	fastio();

	LL h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	LL mint = (h2-h1-1)*60 + 60-m1 + m2;
	LL tim = max(0LL, mint-k);

	cout << tim << "\n";
}

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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

map<string, int> freq;

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

    int n;
    cin >> n;

    int mx=0;
    while (n--) {
        string s;
        cin >> s;

        ++freq[s];
        mx=max(mx, freq[s]);
    }

    for (auto it=freq.begin(); it!=freq.end(); ++it) {
        if (it->S==mx) {
            cout << it->F << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 23808
#include<stdio.h>

void leap_year(int start_year, int end_year);

int main(void)
{
    int start_year;
    int end_year;
    int i = 0;
    while(1) {
        scanf("%d %d", &start_year, &end_year);
        if (start_year == 0 && end_year == 0) {
        break;
        } else {
            if ( i == 1) {
                printf("\n");
            }
            leap_year(start_year, end_year);
            i = 1;
        }
    }
    return 0;
}

void leap_year(int start_year, int end_year)
{
    int n = 0;
    int year = start_year;
    while (year <= end_year) {
        if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
            printf("%d\n", year);
            n++;
        }
        year++;
    }
    if (n == 0) {
    printf("NA\n");
    }
}

 

Measured memory_bytes: 1044
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <functional>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int h, w, m;
	cin >> h >> w >> m;
	vector<int> fw(w, 0);
	set<pair<int, int> > ww;
	vector < vector<int> > b(h);
	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		x--; y--;
		b[x].push_back(y);
		fw[y]++;
	}
	for (int i = 0; i < w; i++)
		ww.insert({ -fw[i], i });
	int ans = 0;
	for (int i = 0; i < h; i++)
	{
		if (!ww.empty()) ans = max(ans, (int)(b[i].size()) - ww.begin()->first - 1);
		for (int y : b[i])
		{
			ww.erase({ -fw[y], y });
		}
		if (!ww.empty()) ans = max(ans, (int)(b[i].size()) - ww.begin()->first);
		for (int y : b[i])
		{
			ww.insert({ -fw[y], y });
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34868
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut a: Vec<i64> = (0..n).map(|_| input()).collect();
    a.sort();

    let mut v = vec![];
    let mut i = 0;
    while i < n {
        let cur = a[i];
        let mut cnt = 0;
        while i < n && a[i] == cur {
            i += 1;
            cnt += 1;
        }
        v.push(cnt);
    }

    println!("{}", v.iter().filter(|&v| v % 2 != 0).count());
}


Measured memory_bytes: 6396
#include<cstdio>
int n;
int main() {
	scanf("%d",&n);
	int a,sum=0;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a);
		while(a%2==0)
			a/=2,sum++;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    string s;
    cin >> s;
    int o = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='o'){o++;}
    }
    cout << 700+100*o << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> m;
    for (auto &&j : v) scanf("%d", &j), m[j]++;
    ll ans = 0;
    for (auto &&i : m) {
        ans += (ll)i.second*(i.second-1)/2;
    }
    for (int i = 0; i < n; ++i) {
        m[v[i]]--;
        ans -= m[v[i]];
        printf("%lld\n", ans);
        ans += m[v[i]];
        m[v[i]]++;
    }
    return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
#include <unordered_map>

int main(void){
	int n, d;
	std::cin >> n >> d;
	std::vector<std::array<int, 10>> x(n);
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			std::cin >> x[i][j];
		}
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int dx2 = 0;
			for(int k=0;k<d;k++){
				int dist = x[i][k] - x[j][k];
				dx2 += dist * dist;
			}
			for(int k=1;k * k <= dx2; k++){
				if(k * k == dx2){
					ans++;
				}
			}
		}
	}
	std::cout << ans << std::endl;
	
}

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

using namespace std;
using ll = long long int;

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

    string s;
    cin >> s;
    char p = '.';
    ll r = 0;
    ll i;
    for(i=0; i<s.size(); i++) {
        if(s[i] == p)
            p = '.', i++;
        else
            p = s[i];
        r++;
    }
    if(i == s.size()+1) r--;
    cout << r << endl;
}


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

int n;
void dfs(string s, char mx)
{
  if (s.size() == n){
    cout << s << endl;
    return;
  }
  for (char c='a'; c <= mx+1; c++)
  {
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}

int main()
{
  cin >> n;
  dfs("", 'a' - 1);
}

Measured memory_bytes: 1536
N, Q = map(int, input().split())
rela = [[] for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    rela[a].append(b)
    rela[b].append(a)
hoge = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    hoge[p] += x
from collections import deque
que = deque([[-1, 0]])
while que:
    par, cur = que.popleft()
    for new in rela[cur]:
        if new == par:
            continue
        hoge[new] += hoge[cur]
        que.append([cur, new])
print(*hoge)


Measured memory_bytes: 65328
#include <stdio.h>

int main() {
  int n, m, i, ans = 0;
  scanf("%d %d", &n, &m);
  
  if (n >= 2)
    for (i = 1; i < n; i++)
      ans += n - i;
  
  if (m >= 2) 
    for (i = 1; i < m; i++)
      ans += m - i;
  
  printf("%d", ans);
  return(0);
}

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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int H_MAX = 2'000'000;

int A[H_MAX+1];
int H = 0;

int parent(int i)   { return i / 2; }
int left(int i)     { return 2 * i; }
int right(int i)    { return 2 * i + 1; }

void maxHeapify(int i) {
    int l = left(i);
    int r = right(i);
    int largest = 0;
    if (l <= H && A[l] > A[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= H && A[r] > A[largest]) {
        largest = r;
    }
    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

void set_key(int i, int k) {
    A[i] = k;
    int p = parent(i);
    if (p > 0 && A[p] < k) {
        A[i] = A[p];
        set_key(p, k);
    }
}

void insert(int k) {
    ++H;
    set_key(H, k);
}

int extract() {
    int max = A[1];
    A[1] = A[H];
    --H;
    maxHeapify(1);
    return max;
}

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

    std::string command;
    int k;
    while (cin >> command) {
        if (command == "end") { break; }
        if (command == "insert") {
            cin >> k;
            insert(k);
        } else if (command == "extract") {
            cout << extract() << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 7044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int d = scanner.nextInt();

		if((d % 4) == 0 || (d % 7) == 0) {
			System.out.println("Yes");
		} else {
			while((d = d -4) > 0) {
				if ((d % 7) == 0) {
					System.out.println("Yes");
					break;
				}
			}
			if (d < 0) {
				System.out.println("No");
			}
		}
		scanner.close();
	}

}

Measured memory_bytes: 21588
N, X = [int(n) for n in input().split()]
m_list = [int(input()) for n in range(N)]

at_least = sum(m_list)
remaining = X - at_least

min_m = min(m_list)

count = N

while True:
    if remaining >= min_m:
        remaining -= min_m
        count += 1
    else:
        break

print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
#define int long long

const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int r; cin >> r;
	cout << r * r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
int ok = 1000*1000*1000+7;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
#define pi  pair<int,int>

int hp[200000];

signed main(){
	
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	hp[1]=0;
	hp[2]=abs(a[1]-a[2]);
		for(int i=3;i<=n;i++){
		hp[i]=min(abs(a[i]-a[i-1])+ hp[i-1],abs(a[i]-a[i-2])+hp[i-2]);
		//cout<<hp[i]<<" ";
	}
	cout<<hp[n];



	

}

 


Measured memory_bytes: 1792
s = input()
cnt = 0
while True:
    if s == "":
        break
    if s[0] == s[-1]:
        s = s[1:-1]
    elif s[0] == "x":
        s = s + "x"
        cnt += 1
    elif s[-1] == "x":
        s = "x" + s
        cnt += 1
    else:
        print(-1)
        exit()
print(cnt)

Measured memory_bytes: 3316
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    int s=in.nextInt();
    if(s>=n)
      System.out.print("unsafe");
    else
       System.out.print("safe");
  }
}

Measured memory_bytes: 35812
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using pii  = pair<int,int>;
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  int N,A[51],B[51],T;
  T=0;
  cin >> N;
  rep(i,N){
    cin >> A[i];
  }
  rep(i,N){
    cin >> B[i];
  }
  rep(i,N){
    if(A[i]>B[i]) T+=A[i]-B[i];
  }
  cout << T << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 5e3;
ll k, q, d[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> k >> q;
  FOR(i, 0, k) cin >> d[i];
  FOR(_, 0, q){
    ll n, x, m;
    cin >> n >> x >> m;
    x %= m;
    --n;
    FOR(i, 0, min(k, n)){
      ll e = d[i]%m, t=(n-i+k-1)/k;
      if(!e) e=m;
      x += e*t;
    }
    cout << n-x/m << endl;
  }
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  string ans="No";
  int L=S.size()/2;
  int cnt=0;
  if(S.size()%2==0){
    for(int i=0; i<L; i++){
      if(S.at(i)==S.at(i+L)) cnt++;
    }
    if(cnt==L) ans="Yes";
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  string out = "No";
  for(int i = 1; i < 10; i++){
    int a = n % i;
    int b = n / i;
    if(a == 0){
      if(b < 10){
      out = "Yes";
      }
    }
  }
    cout << out;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;
vector<int> num;

int main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<ll> pq;
    for (int i = 0; i < n; ++i)
    {
        ll a;
        cin >> a;
        pq.push(a);
    }

    while(m)
    {
        ll a = pq.top();
        pq.pop();
        a /= 2;
        pq.push(a);
        --m;
    }

    ll ans = 0;
    while(!pq.empty())
    {
        ll a = pq.top();
        pq.pop();
        ans += a;
    }

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


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
	int cmin=110,fmax=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
	 	if(s[i]=='C'&&i<cmin)cmin=i;
		else if(s[i]=='F'&&i>fmax)fmax=i;
	}
	if(fmax>cmin)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt();
		int K=sc.nextInt();
		
		double ans=0;
		
		for(int i=1;i<=N;i++) {
			int t=0;
			int v=i;
			while(v<K) {
				v*=2;
				t++;
			}
			//p(t);
			ans+=1/((double)Math.pow(2, t)*N);
			
			
		}
		p(ans);
		
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23764
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) co, d;ut<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll p = x % d;
    ll q = d - p;
    if((x-p)/d >= k){
    	cout << x - k*d << endl;
    }
    else{
    	ll r = (x-p)/d;
    	k -= r;
    	if(k % 2 == 0){
    		cout << p << endl;
    	}
    	else{
    		cout << q << endl;
    	}
    }
    return 0;
}

Measured memory_bytes: 3648
//Tariquzzaman Faisal
//_Faisal101_
//IUT_CSE'19
//190041101

#include<iostream>
#include<stdio.h>
#include<vector>
#include<deque>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<climits>
#include<cmath>
#include<iterator>
#define mp make_pair
#define pb push_back
#define pb push_back
#define fileOut freopen("out.txt","w",stdout)
#define fileIn freopen("in.txt","r",stdout)
#define testcases ll tc,t; cin >> tc; for(t=1; t<=tc; t++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pi acos(-1.0)
#define ll long long

using namespace std;


int main(){
	
	ll limit;
	cin >> limit;
	ll sum = (limit) * (limit + 1) / 2.0;
	ll three = 3;
	while(three <= limit){
		sum -= three;
		three += 3;
	}
	ll five = 5;
	while(five <= limit){
		sum -= five;
		five += 5;
	}
	ll fifteen = 15;
	while(fifteen <= limit){
		sum += fifteen;
		fifteen += 15;
	}

	cout <<sum << endl;
	
	return 0;
}

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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

int main() {
    int x, y;
    cin >> x >> y;
    if (2 * x <= y && y <= 4 * x && y % 2 == 0) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cstring>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P; 
const int N = 1000006;
//////////////////////////////

Int n;
Int a[20][20];
Int dp[1 << 16];
Int cost[1 << 16];

int main() { 
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	for (int s = 0; s < (1 << n); s++) {
		for (int i = 0; i < n; i++) {
			if ((s >> i) % 2 == 0)continue;
			for (int j = i + 1; j < n; j++) {
				if ((s >> j) % 2 == 0)continue;
				cost[s] += a[i][j];
			}
		}
	}

	dp[0] = 0;
	for (int s = 1; s < (1 << n); s++) {
		for (int t = s; t > 0; t = (t - 1) & s) {
			dp[s] = max(dp[s], dp[s - t] + cost[t]);
		}
	}

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

	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, 0, N) {
        cin >> A[i] >> B[i];
    }

    vector<int> indices(N);
    REP(i, 0, N) {
        indices[i] = i;
    }
    sort(begin(indices), end(indices), [&](int a, int b) {
        return A[a] + B[a] > A[b] + B[b];
    });

    ll ans = 0;
    REP(i, 0, N) {
        if (i % 2 == 0) {
            ans += A[indices[i]];
        } else {
            ans -= B[indices[i]];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>

int main(void) {
  int i,j,n,a[101],sub[2];
  scanf("%d",&n);
  for(i = 0; i < n; i++)scanf("%d",&a[i]);
  for(i = 0; i < n; i++){
    for(j = i - 1; j >= 0; j--){
      if(a[j + 1] < a[j]){
        sub[1] = a[j];
        sub[0] = a[j + 1];
        a[j] = sub[0];
        a[j + 1] = sub[1];
      }
      else break;
    }
    for(j = 0; j < n; j++){
      if(j != 0)putchar(' ');
      printf("%d",a[j]);
    }
    putchar('\n');
  }
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)n - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

template<class Monoid> struct SegmentTree{
    int N;
    vector<Monoid> tree;

    //depending on the problem
    Monoid unit;
    using FX = function<Monoid(Monoid,Monoid)>;
    FX func;
    //

    SegmentTree(int _N,Monoid _unit,FX _func) :N(_N),unit(_unit),func(_func) {
        tree.assign(2*N,unit);
        //_build(array);
    }

    void _build(vector<Monoid> &array){
        for (int i = N; i < 2*N; i++) tree[i] = array[i - N];
        for (int i = N - 1;i >= 0; i--) tree[i] = func(tree[i << 1],tree[i << 1|1]);
    }

    void update(int k,Monoid x){
        k += N;
        tree[k] = func(tree[k],x);
        while (k > 1){
            k >>= 1;
            tree[k] = func(tree[k << 1],tree[k << 1|1]);
        }
    }

    Monoid query(int L,int R){
        L += N; R += N;
        Monoid vL = unit,vR = unit;
        while (L < R){
            if (L&1){ vL = func(vL,tree[L]); L ++; }
            if (R&1){ R --; vR = func(tree[R],vR); }
            L >>= 1; R >>= 1;
        }
        return func(vL,vR);
    }

    void debug() {
        rep(i,2*N) cout << "  st[" << i << "] : " << tree[i];
    }
};

int main() {
    int N,Q; cin >> N >> Q;
    SegmentTree<int> st(N,0,[](int a,int b){return (a + b);});
    rep(_,Q) {
        int a,b,c; cin >> a >> b >> c;
        if (a == 0) {
            --b;
            st.update(b,c);
        }
        else {
            --b; --c;
            cout << st.query(b,c + 1) << '\n';
        }
    }
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 12;
const int S = 1e5+5501;

int dp[N][S];
int p[N], c[N];

int rek(int pos, int tot) {
  if (tot <= 0) return 0;
  if (pos < 0) return 1e4;
  int &ret = dp[pos][tot];
  if (ret != -1) return ret;
  ret = rek(pos-1, tot);
  for (int i = 1; i < p[pos]; ++i) {
    ret = min(ret, i+rek(pos-1, tot-i*(pos+1)));
  }
  return ret = min(ret, p[pos]+rek(pos-1, tot-p[pos]*(pos+1)-c[pos]));
}

void solve() {
  memset(dp, -1, sizeof(dp));
  int d, g; scanf("%d%d", &d, &g);
  g /= 100;
  for (int i = 0; i < d; ++i) {
    scanf("%d%d", p+i, c+i);
    c[i] /= 100;
  }
  printf("%d", rek(d-1, g));
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 8788
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  string s;
  cin >> s;
  cout << s.front()<<s.size()-2<<s.back()<<endl;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

/*最長増加or減少部分列----------*/
/*第一引数 : 対象となるvector
  第二引数 : true:狭義 false:広義  デフォルト:false
  第三引数 : true:増加 false:減少  デフォルト:true
*/
template<class T>
std::vector<T> lis(const std::vector<T> &a, bool strict=0, bool UporNot=1) {
    std::vector<T> lis;
    if(UporNot) {
        for(auto &p : a) {
            typename std::vector<T>::iterator iter;
            if(strict) iter = std::lower_bound(lis.begin(), lis.end(), p);
            else iter = std::upper_bound(lis.begin(), lis.end(), p);
            if(lis.end()==iter) lis.emplace_back(p);
            else *iter = p;
        }
    }else {
        vector<T> rev = a;
        reverse(rev.begin(), rev.end());
        for(auto &p : rev) {
            typename std::vector<T>::iterator iter;
            if(strict) iter = std::lower_bound(lis.begin(), lis.end(), p);
            else iter = std::upper_bound(lis.begin(), lis.end(), p);
            if(lis.end()==iter) lis.emplace_back(p);
            else *iter = p;
        }
    }
    return lis;
}

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];

    /*
     * 同じ色のグループは増加部分列を形成する
     * ではそれらのグループの後端となる数の位置はどうあるべきか
     * これは数列の後ろの方にいるほど長い増加部分列の後端になっている方がいい
     * よって後ろから最長増加部分列をとると各増加部分列の後端の数を数えられる
     */

    vi l = lis(a, 0, 0);
    cout << l.size() << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 1788
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
int main() {
  vector<int> vec(3);
  cin >> vec.at(0);
  cin >> vec.at(1);
  cin >> vec.at(2);
  sort(vec.begin(), vec.end());
  if((vec.at(2)-vec.at(0))%2==0&&(vec.at(2)-vec.at(1))%2==0){
    cout << (vec.at(2)-vec.at(0))/2+(vec.at(2)-vec.at(1))/2 << endl;
  }
  else if((vec.at(2)-vec.at(0))%2==1&&(vec.at(2)-vec.at(1))%2==1){
    cout << (2*vec.at(2)-vec.at(1)-vec.at(0))/2 << endl;
  }
  else{
    cout << (2*vec.at(2)-vec.at(1)-vec.at(0))/2+2 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
const int maxn=1e5+5;
int a[maxn];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	if(n==1){
		puts("Yes");
		return 0;
	}
	int res=a[1];
	for(int i=2;i<=n;i++){
		if(res<a[i])res=a[i];
		if(res-a[i]>=2){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

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

    vector<vector<long long>> v(N, vector<long long>(2));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 2; ++j) {
            cin >> v[i][j];
        }
    }

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

    long long ans = 0;

    for (int i = 0; i < N; ++i) {
        long long buyM = min(M, v[i][1]);
        if (M > 0) {
            M -= buyM;
            ans += v[i][0] * buyM;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<algorithm>
const int N=300100;
using namespace std;
typedef long long ll;
ll n,x;
ll sum[N],c[N];
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        c[x]++;
        sum[c[x]]++;
    }
    for(ll i=1;i<=n;i++)
        sum[i]+=sum[i-1];
    //for(ll i=1;i<=n;i++)
    //printf("%lld %lld\n",c[i],sum[i]);
    for(ll i=1;i<=n;i++)
    {
        ll l=1,r=n,ans=0,mid;
        while(l<=r)
        {
            mid=(r-l)/2+l;
            if(mid*i<=sum[mid])
            {
                ans=mid;
                l=mid+1;
            }
            else
                r=mid-1;
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 5504
import sys
import collections

input = sys.stdin.readline


def modInverse(a, p):
    return pow(a, p - 2, p)


def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % p

    denominator = 1
    for i in range(1, k + 1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p


def main():
    N, M = [int(x) for x in input().split()]

    MOD = 10 ** 9 + 7

    def prime_factorization(n):
        i = 2
        factors = []
        while i * i <= n:
            if n % i:
                i += 1
            else:
                n //= i
                factors.append(i)
        if n > 1:
            factors.append(n)
        return factors

    x = prime_factorization(M)

    c = collections.Counter(x)

    ans = 1
    for k in c.keys():
        ans *= modBinomial(c[k] + N - 1, c[k], MOD)

    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  string s;
  cin >> s;
  set<char> st;
  rep(i, sz(s)) st.insert(s[i]);
  cout << (sz(st) == 1 ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
n,s=open(0);n=int(n)
for a,b in ([0,0],[0,1],[1,0],[1,1]):
	r=[a,b]
	for i in range(n):a,b=b,s[-~i%n]=="xo"[a==b];r+=[b]
	if r[:2]==r[-2:]:print(*("WS"[i]for i in r[:-2]),sep="");exit()
print(-1)

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int mindiff(int bit){

    int result = INT_MAX;
    int tmp = 1;

    rep(i, 47){
        if(bit & (1<< (i % 24) + 1)){
            result = min(result, tmp);
            tmp = 1;
        }else{
            tmp++;
        }
    }

    result = min(result, tmp);

    return result;
}


int main(){

    int n;
    cin >> n;

    vector<int> d(n);

    rep(i, n){
        cin >> d[i];
    }

    vector<vector<bool>> dp(n + 1, vector<bool>(1<<24, false));

    dp[0][1] = true;

    rep(i, n){
        rep(j, (1<<24)){
            if(dp[i][j]){

                if(d[i] == 0){

                }else{

                    if(j & (1<<d[i])){

                    }else{
                        dp[i + 1][j + (1<<d[i])] = true;
                    }

                    if(j & (1<<(24 - d[i]))){

                    }else{
                        dp[i + 1][j + (1<<(24 - d[i]))] = true;
                    }

                }

            }
        }
    }

    int ans = 0;
    
    rep(i, (1<<24)){
        if(dp[n][i]){
            ans = max(ans, mindiff(i));
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 107008
# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, A, B):
    buf = -1
    key = 0
    for i in range(N):
        if buf != A[i]:
            key = 0  # 前回(A[i - 1])と同じ値じゃなければリセット
        if A[i] == B[i]:
            for j in range(key, N):
                if A[i] != A[j] and B[j] != A[i]:
                    B[i], B[j] = B[j], B[i]
                    key = j
                    break
            else:
                print('No')
                return
        buf = A[i]
    print('Yes')
    print(' '.join([str(i) for i in B]))


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    # ABi = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N, A, B)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


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

using namespace std;
typedef long long ll;

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

int gcd(int a, int b)
{
	return (!b ? a : gcd(b, a % b));
}

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

	ll ans = 0;
	for (ll a = 1; a * a < 1e6 + 1; a++)
	{
		for (ll b = a + 1; b < 1e6 + 1; b++)
		{
			int c = n - a * b;
			if (0 < c)
			{
				ans++;
			}
		}
	}
	ans *= 2;

	for (ll a = 1; a * a < 1e6 + 1; a++)
	{

		int c = n - a * a;
		if (0 < c)
		{
			ans++;
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3632