akhauriyash/Code-Regression huggingface dataset:
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N, K;
	cin >> N >> K;
	vector<int>x(N);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		ans += min(x[i], abs(K - x[i]));
	}
	cout << ans * 2 << endl;
}


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

using namespace std;

int k,n;
int v[200010];
long long b[200010];

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


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


    for (int i = 1; i < n; ++i) 
        b[i] = v[i] - v[i - 1];
    
    b[n] = abs(v[0] + k - v[n - 1]);

    for (int i = 1; i <= n; ++i)
        b[i] += b[i - 1];


    long long ans = 1e14;


    for (int i = 1; i < n; ++i) {
        ans = min(ans, b[n] - abs(v[i % n] - v[(i - 1 + n) % n]));
    }
    ans = min(ans, b[n] - (long long)abs(v[0] + k - v[n - 1]));
    cout << ans <<"\n";

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define MOD 998244353

using namespace std;

typedef long long ll;

inline void update(int &x,ll y) {
  x=(x+y)%MOD;
}

int C[6005][6005],f[2][2][6005][6005];

void pre(int n) {
  for(int i=0;i<=n;i++) C[i][0]=1;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
  for(int t1=0;t1<2;t1++) {
  	f[t1][t1][0][0]=1;
  	for(int i=0;i<n;i++)
  	  for(int j=0;j<=i;j++) {
  	  	  update(f[t1][1][i+1][j+1],f[t1][0][i][j]);
  	  	  update(f[t1][0][i+1][j],f[t1][1][i][j]);
  	  	  update(f[t1][1][i+1][j+1],f[t1][1][i][j]);
		}
  }
}

bool in[6005];

int dp(int n,int m,int k) {
  if (n<m) {
  	int ans=0;
  	for(int j=0;j<n;j++) {
  	  update(ans,(ll)f[1][0][n-1][j]*C[k][j+1]);
  	  update(ans,(ll)f[1][1][n-1][j]*C[k][j+1]);
    }
    return ans;
  }
  else if (2*m>n) {
    memset(in,0,sizeof(in));
    in[m]=0;in[0]=1;
    for(int j=m+1;j<=n;j++) {
  	  in[j]=(in[j-1]^1);
  	  in[j-m]=(in[j]^1);
    }
    if (!in[n]) return 0;
    int s=0;
    for(int i=1;i<=n;i++) s+=in[i];
    int len=m-(n-m)-1,ans=0;
    for(int j=0;j<=len;j++) {
  	  if (in[m]) update(ans,(ll)f[in[n-m]][0][len][j]*C[k][j+s]);
  	  update(ans,(ll)f[in[n-m]][1][len][j]*C[k][j+s]);
    }
    return ans;
  }
  else return ((m&1)&&!(n&1))?C[k][n>>1]:0;
}

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  pre(2*n);
  int ans=0;
  for(int i=1;i<=2*n;i++)
    update(ans,dp(i,m,n));
  printf("%d\n",(ans+1)%MOD);
  return 0;
}

Measured memory_bytes: 702720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 cin >> N;
 int ans = 0; 
  
  while ( N > 0 ){
    ans += N % 10;
    N /= 10;
  }
  if (ans == 1 ) cout << 10 << endl;
  else cout << ans << endl; 
  }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

	if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
		cout << "infinity" << endl;
		return 0;
	}

	if (a1 < b1) {
		swap(a1, b1);
		swap(a2, b2);
	}

	int64_t l = t1 * a1 + t2 * a2 - t1 * b1 - t2 * b2;
	if (l > 0) {
		cout << 0 << endl;
		return 0;
	}
	int64_t s = t1 * a1 - t1 * b1;
	int64_t ans = -(s / l) * 2;
	if (s % l != 0) ans++;

	cout << max(ans, (int64_t)0) << endl;


	return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
n, m = list(map(int, input().split()))
dp = [0]*(n+1)
dp[0] = 1
s = set()
for i in range(m):
    a = int(input())
    s.add(a)

for i in range(n):
    if i in s:
        continue
    for j in range(1,3):
        if i+j <= n:
            dp[i+j] = (dp[i+j] + dp[i])%mod

print(dp[-1])

Measured memory_bytes: 12652
#include <iostream>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    if (c >= a && c <= b)
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
    std::cout << std::endl;
    return 0;
}


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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define scan(n)         scanf("%d",&n)
#define pb              push_back
#define vi              vector<int>
#define ii              pair<int,int>

using namespace std;

int main(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}


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

int main()
{

    int N = 100010;
    int Q;
    cin >> Q;
    vector<bool> prime_numbers(N, true);
    // Sieve of Eratosthenes
    prime_numbers[0] = false;
    prime_numbers[1] = false;
    for (int i = 2; i * i < N; i++)
    {
        if (!prime_numbers[i])
            continue;
        for (int j = i * 2; j < N; j = j + i)
        {
            prime_numbers[j] = false;
        }
    }

    // 2017-likeかどうか
    vector<int> a(N, 0);
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
            continue;
        if (prime_numbers[i] && prime_numbers[(i + 1) / 2])
            a[i] = 1;
    }

    // 累積和を計算
    vector<long long> sum(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        sum[i + 1] = a[i] + sum[i];
    }

    for (int i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        r++;
        cout << sum[r] - sum[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long h[100001];
int main()
{
  int n,k;
  cin>>n>>k;
  for (int i=1;i<=n;i++)
  {
    cin>>h[i];
  }
  sort(h+1,h+n+1);
  long long mn=99999999999;
  for (int i=1;i<=n-k+1;i++)
  {
    if (h[k+i-1]-h[i]<mn) mn=h[k+i-1]-h[i];
  }
  cout<<mn;
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))

b = []
total = 0

for i in range(n):
    b.append(0)

for i in range(n):
    b[a[i]-1] += 1
for i in range(n):
    if b[i] >= 2:   
        total += b[i]*(b[i]-1)//2



for i in range(n):
    ans = total
    ans -= b[a[i]-1]*(b[a[i]-1]-1)//2
    b[a[i]-1] -= 1
    ans += b[a[i]-1]*(b[a[i]-1]-1)//2
    print(ans)
    b[a[i]-1] += 1


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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    string s,t;
    cin >> s >> t;
    int ans=0;
    for (int i=0;i<3;i++) if (s[i]==t[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    ll N, D;
    cin >> N >> D;
    ll res = 0;
    rep(i, N) {
        ll x, y;
        cin >> x >> y;
        if (x*x + y * y <= D * D) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> S(N+1,0), T(M+1,0);
    vector<vector<vector<int>>> dp(N+2,vector<vector<int>>(M+2,vector<int>(2,0)));
    for (int i=0;i<N;i++) cin >> S[i];
    for (int j=0;j<M;j++) cin >> T[j];
    dp[0][0][0] = 1;
    for (int i=0;i<=N;i++) for (int j=0;j<=M;j++) {
        dp[i+1][j][0] = (dp[i+1][j][0] + dp[i][j][0]) % MOD;
        dp[i][j][1] = (dp[i][j][1] + dp[i][j][0]) % MOD;
        dp[i][j+1][1] = (dp[i][j+1][1] + dp[i][j][1]) % MOD;
        if (S[i] == T[j]) dp[i+1][j+1][0] = (dp[i+1][j+1][0] + dp[i][j][1]) % MOD;
    }
    cout << dp[N][M][1] << endl;
    return 0;
}


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

using namespace std;

int main()
{
	int n; string s;
	cin >> n;
	cin >> s;
	if (n > 0)
	{
		for ( int i = 0; i < int( s.size() ); ++i )
		{
			int auxletter = int ( s[i] ) + n;
			if( auxletter >= 91 ) auxletter = 65 + ( auxletter - 91 );  
		
			s[i] = char(auxletter);
		}
	}
	
	
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e5+6;
int n, T, c, x;
string a, b;
int dp[M] , h[M];
int k;
int go (int i) {
    if (i==n-1)
        return 0;
    int &res = dp[i];
    if (res+1)return res;
    res = 1e9;
    for (int j=1;j<=k;j++) {
            if (i+j<n)
        res = min(res,go(i+j)+abs(h[i+j] - h[i]));

    }
    return res;
}
int main () {
    memset(dp,-1,sizeof dp);

    scanf("%d %d",&n,&k);
    for (int i=0;i<n;i++)
        scanf("%d",h+i);
    /*for (int i=1;i<=k;i++){
        dp[i] = abs(h[i] - h[0]);
    }
    for (int i=k+1;i<n;i++)
        for (int j=1;j<=k;j++){
            int res = 1e7;
            res = min(res,dp[i-j] + abs( h[i-j]-h[i] ));
            dp [i] = res;

    }
    cout << dp[n-1] << endl;
    */
    cout << go(0);
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            long double sum = 0;
            for (int k = 0; k < d; ++k)
            {
                sum += pow(x[i][k] - x[j][k], 2.0);
            }
            sum = sqrt(sum);
            if (sum == (int)sum)
                ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N, M, X, Y;
	cin >> N >> M >> X >> Y;
	ll x[N+1], y[M+1];
	for (int i = 0; i < N; ++i) cin >> x[i];
	x[N] = X;
	for (int i = 0; i < M; ++i) cin >> y[i];
	y[M] = Y;
	
 
	// 解法
	sort(x, x + N+1);
	sort(y, y + M+1);
	
	// cout << x[N-1] << endl;
	// cout << y[0] << endl;
	if (x[N]<y[0]) printf("No War");
	else printf("War");
}
 


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

string A, B, C;

char check(int a_i, int b_i, int c_i, char turn) {
    if (turn == 'A') {
        if (a_i == A.length()) return 'A';
        else {
            if (A[a_i] == 'a') return check(a_i + 1, b_i, c_i, 'A');
            else if (A[a_i] == 'b') return check(a_i + 1, b_i, c_i, 'B');
            else return check(a_i + 1, b_i, c_i, 'C');
        }
    }
    else if (turn == 'B') {
        if (b_i == B.length()) return 'B';
        else {
            if (B[b_i] == 'a') return check(a_i, b_i + 1, c_i, 'A');
            else if (B[b_i] == 'b') return check(a_i, b_i + 1, c_i, 'B');
            else return check(a_i, b_i + 1, c_i, 'C');
        }
    }
    else {
        if (c_i == C.length()) return 'C';
        else {
            if (C[c_i] == 'a') return check(a_i, b_i, c_i + 1, 'A');
            else if (C[c_i] == 'b') return check(a_i, b_i, c_i + 1, 'B');
            else return check(a_i, b_i, c_i + 1, 'C');
        }
    }
}

int main() {
    cin >> A >> B >> C;
    
    char ans = check(0, 0, 0, 'A');

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}
inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n, h; cin>>n>>h;
  vector<pair<int, int>> ab(n);
  rep(i, n) cin>>ab[i].first>>ab[i].second;

  sort(ab.begin(), ab.end(), greater<pair<int, int>>());
  int huru = ab[0].first;
  sort(ab.begin(), ab.end(), [](pair<int, int> &x, pair<int, int> &y) {return x.second > y.second;});

  int ans = 0;
  rep(i, n) if (ab[i].second > huru) {
    h -= ab[i].second;
    ++ans;
    if (h <= 0) {
      print(ans);
      return 0;
    }
  }
  ans += h / huru;
  if (h % huru) ++ans;
  print(ans);

  return 0;
}

Measured memory_bytes: 1024
s = input()
a = [0] * (len(s)+1)

for i in range(len(s)):
  if s[i] == "<":
    a[i+1] = a[i] + 1

for i in range(len(s)-1, -1, -1):
  if s[i] == ">":
    a[i] = max(a[i], a[i+1]+1)

print(sum(a))

Measured memory_bytes: 23336
s = gets.chomp
len = s.size
n = (len / 2) - 1
ans = 0
(1..n).each do |i|
    pos = len - (2*i) - 1
    stt = (len / 2) - i
    h = s[stt..pos]
    t = s[0..stt-1]
    if h == t
        ans = pos + 1
        break
    end
end

puts ans

Measured memory_bytes: 1788
import java.util.*;
import java.lang.*;


public class Main {
    static int n;
    static int f[][];
    static int p[][];
    static long max = -1000000001;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        f = new int[n][10];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 10; j++) {
                f[i][j] = sc.nextInt();
            }
        }
        p = new int[n][11];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 11; j++) {
                p[i][j] = sc.nextInt();
            }
        }
        int dub[] = new int[n];
        dfs(0, dub);
        System.out.println(max);
    }
    static void dfs(int time, int[] dub) {
        if (time == 10) {
            boolean mu = false;
            for (int i = 0; i < n; i++) {
                if (dub[i] != 0) {
                    mu = true;
                    break;
                }
            }
            if (mu) {
                int benefit = 0;
                for (int i = 0; i < n; i++) {
                    benefit += p[i][dub[i]];
                }
                max = Math.max(max, benefit);
                return;
            } else {
                return;
            }
        }
        dfs(time + 1, dub);
        int d[];
        d = Arrays.copyOf(dub, n);
        for (int i = 0; i < n; i++) {
            if (f[i][time] == 1) {
                d[i]++;
            }
        }
        dfs(time + 1, d);
    }
}

Measured memory_bytes: 27224
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 300

	int anX[10000];

int main() {

	int i=0;
	int j=0;
	int nNumber=0;
	int nOpe=0;

	// read line 1
    scanf("%d", &nNumber);
	// read line 2
	for(i=0; i<nNumber; i++) {
        scanf("%d", &anX[i]);
	}
	for(i=0; i<nNumber; i++) {
        while(anX[i]%2==0){
			anX[i]=anX[i]/2;
			nOpe++;
		}
	}

	printf("%d\n",nOpe);

    return 0;
}



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

#define int long long 

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,m,b[maxn],l[maxn],r[maxn],ans,s[maxn],t[maxn];

int check(int x) {
    for(int i=1;i<=n;i++) {
        int c=x/m,d=x%m;
        int res=l[i]*min(b[i],d)+r[i]*max(0ll,d-b[i]),w=l[i]*b[i]+r[i]*(m-b[i]);// write(t[c+1]);
        if(c) {
            if(w<s[c]) res+=t[c];
            else res+=t[c+1]-w;
        }
        res-=ans;// printf("%I64d %I64d %I64d\n",x,i,res);
        if(res>=0) return 1;
    }
    return 0;
}

signed main() {
    read(n),read(m);
    for(int i=1;i<=n;i++) read(b[i]),read(l[i]),read(r[i]),ans+=b[i]*l[i],s[i]=b[i]*l[i]+(m-b[i])*r[i];
    sort(s+1,s+n+1,greater<int > ());
    for(int i=1;i<=n;i++) t[i]=s[i]+t[i-1];
    int l=0,r=n*m,ans=n*m;
    while(l<=r) {
        int mid=(l+r)>>1;
        if(check(mid)) r=mid-1,ans=mid;
        else l=mid+1;
    }
    write(ans);
    return 0;
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define inf (int)(3e18)
#define all(v) v.begin(),v.end()
#define mod (int)(1e9+7)

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int K,N;
int A[200005];
signed main() {
	cin>>K>>N;
	int ma=-inf;
	rep(i,N){
		cin>>A[i];
		if(i)chmax(ma,A[i]-A[i-1]);
	}
	chmax(ma,A[0]+K-A[N-1]);
	cout<<K-ma<<endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll a[200000];
ll x[200000];//i以下の和

int main()
{
	int n;
	ll ans=99999999999999;
	fill(x,x+200000,0);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		x[i]=a[i];
		if(i>0)
			x[i]+=x[i-1];
	}

	for(int i=0;i<n-1;i++)
	{
		ll t = abs(x[n-1]-x[i]-x[i]);
		if(t<ans)
			ans=t;
	}

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

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 2e5 + 5;

int n,m,ans,f[N];

void init(int x) {for(int i=0;i<=x;i++) f[i]=i;}

int find(int x) {return f[x]==x?x:f[x]=find(f[x]);}//路径压缩

inline void merge(int x, int y) {int a=find(x),b=find(y);if(a!=b) f[b]=a;}//“靠左”原则

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m;
    init(n);
    for(int i=1;i<=m;i++){
    	int u,v;
    	cin>>u>>v;
    	merge(u,v);
    }
    unordered_map<int,int> cnt;
    for(int i=1;i<=n;i++){
    	int j=find(i);
    	cnt[j]++;
    	ans=max(ans,cnt[j]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 12004
# t=int(input(""))
t=1
for _ in range(t):
    k=int(input(""))
    A=[1,2,3,4,5,6,7,8,9]
    i=0
    while(len(A)<=k):
        if(A[i]%10==0):
            A.append(A[i]*10+(A[i])%10)
            A.append(A[i]*10+(A[i]+1)%10) 
        elif(A[i]%10==9):
            A.append(A[i]*10+(A[i]-1)%10)
            A.append(A[i]*10+(A[i])%10)
        else:
            A.append(A[i]*10+(A[i]-1)%10)
            A.append(A[i]*10+(A[i])%10)
            A.append(A[i]*10+(A[i]+1)%10)
        i+=1
    # print(A)
    print(A[k-1])
        
    

Measured memory_bytes: 7256
#include<bits/stdc++.h>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
const int big=0x7fffffff;
using namespace std;
inline void read(int &x)
{
    x=0;char ch=getchar();int pd=1;
    while(ch<'0'||ch>'9'){if(ch=='-')pd=-pd;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    x*=pd;
}
inline void write(const int &x)
{
    char ggg[10001];int s=0;int tmp=x;
    if(tmp==0){putchar('0');return;}
    if(tmp<0){tmp=-tmp;putchar('-');}
    while(tmp>0){ggg[s++]=tmp%10+'0';tmp/=10;}
    while(s>0){putchar(ggg[--s]);}
}
const int N=1e5+233;
int mx[N],vis[N],t,h[N];

struct dd
{
	int end,nt;
}e[N<<1];

inline void add(int begin,int end)
{
	++t;
	e[t].end=end;
	e[t].nt=h[begin];
	h[begin]=t;
}

void dfs(int x,int d,int s)
{
	if(mx[x]>=d)return;
	if(!vis[x])vis[x]=s;
	mx[x]=max(mx[x],d);
	if(!d)return;
	for(register int i=h[x];i;i=e[i].nt)
	{
		int u=e[i].end;
		dfs(u,d-1,s);
	}
}
const int Q=1e5+233;
int n,m,q,xx[N],d[N],c[N];



int main()
{
	memset(mx,-1,sizeof(mx));
	read(n);
	read(m);
	for(register int i=1;i<=m;++i)
	{
		int xx,yy;
		read(xx);
		read(yy);
		add(xx,yy);
		add(yy,xx);
	}
	read(q);
	for(register int i=1;i<=q;++i)
	{
		read(xx[i]);
		read(d[i]);
		read(c[i]);
	}
	for(register int i=q;i>=1;--i)
	{
		dfs(xx[i],d[i],c[i]);
	}
	for(register int i=1;i<=n;++i)
	{
		write(vis[i]);
		putchar('\n');
	}
	return 0;
}

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

char s[55];
char t[55];
int main()
{
	scanf("%s%s",s,t);
	int len=strlen(s);
	int len1=strlen(t);
	int i=0,j=0,st=0,flag=0;
	int st1=0; 
	for(int i=0;i<len;i++)
	{
		for(int j=0;j<len1&&i+j<len;j++)
		{
			if(s[i+j]!=t[j]&&s[i+j]!='?') break;
			if(j==len1-1)
			{
				flag=1;
				st=i;
			}
		}
	}
	if(flag)
	{
		for(i=0;i<len;i++)
		{
			if(i==st)
			{
				for(int j=0;j<len1;j++)
				{
					cout<<t[j];
				}
				i+=len1-1;
			}
			else {
				if(s[i]=='?') cout<<"a";
				else cout<<s[i];
			}
		}
	}
	else cout<<"UNRESTORABLE";
}


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

using namespace std;

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

  int n;
  cin >> n;

  vector<int> ans(n);
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    ans[a - 1] = i;
  }

  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << '\n';

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
#define PI 3.14159265358979323846264338327950L

int main() {
	int n,m;
  	cin>>n>>m;
  
  	vector<vector<int>> vec(m);
  
  	for(int i=0;i<m;i++){
    	int k;cin>>k;
      	vec[i].resize(k);
      	for(int j=0;j<k;j++){
        	cin>>vec[i][j];
          	--vec[i][j];
        }
    }

  	vector<int>p(m);
  	for(int i=0;i<m;i++)cin>>p[i];
  
  	int ans=0;
  	for(int i=0;i<(1<<n);i++){
    	bool ok=true;
      	for(int j=0;j<m;j++){
        	int c=0;
          	for(int id:vec[j]){
            	if((i>>id)&1){
                	c++;
                }
            }
          c%=2;
          if(c!=p[j]){
          	ok=false;
          }
        }
      if(ok){
      	ans++;
      }
    }	
cout<<ans<<endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define M 1000000007
#define vll vector<ll>
#define pll pair<ll, ll>
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin(), (x).end()
ll a[1000000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ll t, n, i, j, c, k, m, x, y, f, ans;
  string s;
  ans = 0;
  cin >> s;
  for (i = 0; s[i]; i++) {
    ans += s[i] - '0';
  }
  if (ans % 9)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}


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

typedef long long ll;

int main() {
int N, M, L, R;  cin >> N >> M;
int L_max = 0;
int R_min = N;
for (int i = 0; i < M; i++) {
    cin >> L >> R;
    L_max = max(L_max, L);
    R_min = min(R_min, R);
}

cout << max(0, R_min - L_max + 1) << endl;

}

Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Thu Mar 26 22:17:55 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import Counter

s = ns()
n = len(s)

def runlength(a):
    res = []
    last = None
    c = -1
    for i in a:
        if last == i:
            res[c][1] += 1
            last = i
        else:
            c += 1
            res.append([i, 1])
            last = i
    return res

a = runlength(s)
ans = [0] * n
cur = 0
i = 0
while i < len(a) - 1:
    p = a[i]
    q = a[i + 1]
    pl = p[1]
    ql = q[1]
    ans[cur + pl] = pl // 2 + (ql - ql // 2)
    ans[cur + pl - 1] = (pl - pl // 2) + ql // 2
    cur += pl + ql
    i += 2

print(*ans)

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

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

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

    int q;
    cin >> q;

    int b, e, k;
    for(int i = 0; i < q; i++){
        cin >> b >> e >> k;
        int cnt = 0;
        for(int i = b; i < e; i++)  cnt += (a[i] == k);
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
import sys
n = int(input())
H = list(map(int, input().split()))
dp = [False] * n

for i in range(n-1):
  if H[i+1] - H[i] < -1:
    print("No")
    break
  elif H[i+1] - H[i] == -1:
    for j in range(i+1, 0, -1):
      if dp[j-1] == True:
        print("No")
        sys.exit()
      elif H[j] - H[j-1] >= 1:
        break
      else:
        dp[j-1] = True
else:
  print("Yes")

Measured memory_bytes: 63856
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;

int main() {
	ll N, min = 0, num = 0;
	cin >> N;
	ll* a = (ll*)malloc(sizeof(ll)*N);
	for (ll i = 0;i < N;i++)cin >> a[i];
	sort(a, a + N);
	if (a[N-1] % 2 == 0) {
		min = abs(a[N-1] / 2 - a[0]);
		num = a[0];
		for (ll i = 0;i < N;i++) {
			if (min > abs(a[N-1] / 2 - a[i])) {
				min = abs(a[N-1] / 2 - a[i]);
				num = a[i];
			}
		}
		cout << a[N - 1] << " " << num << endl;
		return 0;
	}
	else {
		min = abs(a[N - 1] / 2 - a[0]);
		num = a[0];
		for (ll i = 0;i < N;i++) {
			if ((a[i] == (a[N-1] + 1) / 2) || (a[i] == (a[N-1] - 1) / 2)) {
				cout << a[N - 1] << " " << a[i] << endl;
				return 0;
			}
			else {
				if (min > abs(a[N-1] / 2 - a[i])) {
					min = abs(a[N-1] / 2 - a[i]);
					num = a[i];
				}
			}
		}
		cout << a[N - 1] << " " << num << endl;
		return 0;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1e9 + 7;

int euler(int n) {
  VI ps;
  {
    int tmp = n;
    for (int x = 2; x * x <= tmp; x++) {
      if (tmp % x) continue;
      ps.push_back(x);
      while (tmp % x == 0) tmp /= x;
    }
    if (tmp != 1) ps.push_back(tmp);
  }
  int m = ps.size();
  int ans = 0;
  REP (bit, 1LL << m) {
    int d = 1;
    REP (i, m) {
      if (bit >> i & 1) d *= ps[i];
    }
    int sign = __builtin_popcount(bit) % 2 ? -1 : 1;
    ans += sign * (n / d);
  }
  return ans;
}
signed main() {
  int n; cin >> n;
  cout << euler(n) << endl;
}



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

long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
   
    
   int binomial(int n, int k)  
{  
    // Base Cases  
    if (k == 0 || k == n)  
        return 1;  
  
    // Recur  
    return binomial(n - 1, k - 1) + binomial(n - 1, k);  
}   

bool Sieve(ll int n) 
{ 
    
    bool prime[n+100000]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    return prime[n];
}
  
    
vector<long long> factor;  
vector<long long>prime(long long n) {
 for (long long d = 2; d * d <= n; d++) {
     while (n % d == 0) {
         factor.push_back(d);
            n /=d;
        }
    }
 if (n > 1)
    factor.push_back(n);
    return factor;
}




//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}


  
int main() {
   int x,n;
   cin>>x>>n;
   int a[n];
   map<int,int>mp;
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
        mp[a[i]]=1;
     }
     int k=0;
     for(int i=0;i<1000;i++)
     {
         if(mp.find(x-k)==mp.end())
         {
             cout<<x-k<<endl;
             break;
         }
         else if(mp.find(x+k)==mp.end())
         {
             cout<<x+k<<endl;
             break;
         }
         k++;
     }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int n;
	cin >> n;
	int a[3];
	for (int i = 0; i < n; i++) {
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3, greater<int>());
		if (a[0]*a[0] == a[1]*a[1] + a[2]*a[2]) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3112
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	long long a,b,c;
	scanf("%lld%lld.%lld",&a,&b,&c);
	printf("%lld\n",a*b+a*c/100);
}

Measured memory_bytes: 1736
from fractions import gcd
a, b, c, d = map(int, input().split())
n = b - a + 1
x = b//c - (a-1)//c
y = b//d - (a-1)//d
lcm = c*d//gcd(c, d)
z = b//lcm - (a-1)//lcm
print(n - (x + y - z))

Measured memory_bytes: 63980
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int A=0,B=0,C=0;

  cin >> A >> B >> C;
  cout << ((A<=C)&&(C<=B)?"Yes":"No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
const int MOD=1e9+7;
int a[N];

int cmp(int a,int b)
{
    return a>b;
}
string s;
map<ll,int> mp;
const int minn=-1e9-10;
int b[N];
const int maxx=1e9+10;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    ll ans=0;
    for(int i=2;i<=n;i++){
        if(a[i]<a[i-1]) {ans+=a[i-1]-a[i];
        a[i]=a[i-1];
        }
    }
    cout<<ans<<endl;
}






Measured memory_bytes: 4400
L = list(input())
n = len(L)
mod = 10**9+7
 
dp = [[0]*2 for i in range(n+1)]
dp[0][0] = 1
 
for i,c in enumerate(L):
    if c == '1':
        dp[i+1][0] = dp[i][0]*2%mod
        dp[i+1][1] = (dp[i][0]+dp[i][1]*3)%mod
    else:
        dp[i+1][0] = dp[i][0]%mod
        dp[i+1][1] = dp[i][1]*3%mod
print(sum(dp[-1])%mod)

Measured memory_bytes: 20388
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

manhattan = 0
euclidean = 0
p3 = 0
chebyshev = []
for i in range(n) :
    manhattan += abs(x[i] - y[i])
    euclidean += abs(x[i] - y[i]) ** 2
    p3 += abs(x[i] - y[i]) ** 3
    chebyshev.append(abs(x[i] - y[i]))

euclidean = math.sqrt(euclidean)
p3 = p3 ** (1/3)
chebyshev = max(chebyshev)

print(manhattan)
print(euclidean)
print(p3)
print(chebyshev)


Measured memory_bytes: 5692
unittest
{
	assert( [ "6", "AC", "TLE", "AC", "AC", "WA", "TLE" ].solve == "AC x 3\nWA x 1\nTLE x 2\nRE x 0" );
	assert( [ "10", "AC", "AC", "AC", "AC", "AC", "AC", "AC", "AC", "AC", "AC" ].solve == "AC x 10\nWA x 0\nTLE x 0\nRE x 0" );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto ss = new dchar[][ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.to!( dchar[] );
	}
	
	auto ac = 0L;
	auto wa = 0L;
	auto tle = 0L;
	auto re = 0L;
	foreach( s; ss )
	{
		final switch( s )
		{
			case "AC" : ac++;  break;
			case "WA" : wa++;  break;
			case "TLE": tle++; break;
			case "RE" : re++;  break;
		}
	}
	return format( "AC x %s\nWA x %s\nTLE x %s\nRE x %s", ac, wa, tle, re );
}


Measured memory_bytes: 11804
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	int ans = 0;
	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		ans += 2 * min(abs(x), abs(x - k));
	}
	cout << ans << 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);
		final String END_OF_TEXT = "END_OF_TEXT", WORD = sc.nextLine();
		int count = 0;
		while (sc.hasNext()) {
			String text = sc.next();
			if (text.equals(END_OF_TEXT)) break;
			if (text.equalsIgnoreCase(WORD)) count++;
		}
		sc.close();
		System.out.println(count);	
	}
}

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>x;
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	IN(n);
	vi a(n), b(n), c(n);
	F(n) cin>>a[i];
	F(n) cin>>b[i];
	F(n) cin>>c[i];
	sortv(a);
	sortv(b);
	sortv(c);
	vi cnt(n);
	vi cnt1(n);
	int j=0, i=0;
	while(i<n) {
		while(j<n && a[j]<b[i]) j++;
		cnt[i] = j;
		i++;
	}
	vll p(n);
	p[0] = cnt[0];
	FI(n-1) p[i] = p[i-1]+cnt[i];
	j=0, i=0;
	while(i<n) {
		while(j<n && b[j]<c[i]) j++;
		cnt1[i] = j;
		i++;
	}
	ll ans = 0;
	//F(n) cout<<cnt[i]<<' ';cout<<endl;
	//F(n) cout<<cnt1[i]<<' ';cout<<endl;
	F(n) {
		if(cnt1[i]) ans += p[cnt1[i]-1];
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

template<typename Integer = int_fast64_t>
constexpr Integer extgcd(Integer a, Integer b, Integer &x, Integer &y){
    Integer u = 0, v = 1, q = 0, tmp = 0;
    x = v = 1;
    y = u = 0;

    while(b){
        q = a / b;
        x ^= u ^= x ^= u;
        u = u - q * x;
        y ^= v ^= y ^= v;
        v = v - q * y;
        a ^= b ^= a ^= b;
        b = b - q * a;
    }

    return a;
}

template<uint_fast64_t MOD, typename Integer = int_fast64_t>
constexpr Integer modinv(Integer val){
    int_fast64_t ret = 0, tmp = 0;

    extgcd<int_fast64_t>(static_cast<int_fast64_t>(val), static_cast<int_fast64_t>(MOD), ret, tmp);

    return static_cast<Integer>(ret > 0 ? ret % MOD : (MOD - (-ret % MOD)));
}

template<std::size_t N, std::uint_fast64_t MOD>
struct Fact {
    std::uint_fast64_t val[N], v2[N];

    constexpr Fact() : val(), v2() {
        val[0] = 1;
        for (std::size_t i = 1; i < N; ++i) val[i] = val[i - 1] * i % MOD;
    }
};

template<std::size_t N, std::uint_fast64_t MOD, std::uint_fast64_t F>
struct IFact {
    std::uint_fast64_t val[N];

    constexpr IFact() : val() {
        val[N - 1] = F;
        for (std::size_t i = N - 1; i; --i) val[i - 1] = val[i] * i % MOD;
    }
};

constexpr std::uint_fast64_t MOD = 998244353, maxN = 300001;

constexpr auto fact = Fact<maxN, MOD>();
constexpr auto ifact = IFact<maxN, MOD, modinv<MOD>(fact.val[maxN - 1])>();

constexpr std::uint_fast64_t binommod(std::uint_fast64_t n, std::uint_fast64_t r){
    if(r < 0 || r > n)return 0;
    return fact.val[n] * (ifact.val[r] * ifact.val[n - r] % MOD) % MOD;
}

long long int N, M, A, B, K, ans;

int main(){
    using namespace std;
    scanf("%lld%lld%lld%lld", &N, &A, &B, &K);
    M = min(N, K / A);
    for(int i = 0; i <= M; ++i){
        if((K - i * A) % B == 0){
            ans += binommod(N, i) * binommod(N, (K - i * A) / B);
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;

    ll res = 0;
    // N = p * b + r とする
    // 0, 1, 2, ... b-1, 0, 1, 2...の繰り返し
    for(ll b = 1; b <= n; ++b) {
        if (k >= b) continue;
        ll p = n / b;
        ll r = n % b;
        res += p * max(0ll, b - k) + max(0ll, r + 1 - k);
    }

    if (k == 0) res -= n;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();


            string s = Console.ReadLine();
            int N = s.Length + 1;
            List<long> len = new List<long>();
            long l = 0;
            for (var i = 0; i < N - 1; i++)
            {
                l++;
                if (i == N - 2)
                {
                    len.Add(l);
                    continue;
                }
                if (s[i] != s[i + 1])
                {
                    len.Add(l);
                    l = 0;
                }
            }
            int c = len.Count();
            
            long ans = 0;
            if (s[0] == '<')
            {
                if (c % 2 != 0) { len.Add(0);c++; }
                for (var i = 0; i < c; i += 2)
                {
                    ans += (len[i] * (len[i] - 1) / 2) + (len[i + 1] * (len[i + 1] - 1) / 2);
                    ans += Max(len[i], len[i + 1]);
                }
            }
            else
            {
                len.Insert(0, 0);c++;
                if (c % 2 != 0) { len.Add(0);c++; }
                for(var i = 0; i < c; i += 2)
                {
                    ans += (len[i] * (len[i] - 1) / 2) + (len[i + 1] * (len[i + 1] - 1) / 2);
                    ans += Max(len[i], len[i + 1]);
                }
            }

            Console.WriteLine(ans);
           
            //Console.Out.Flush();

        }
    }


    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

}


Measured memory_bytes: 16992
#include<stdio.h>
int main()
{
	int x,y,a[4],b[5],hit,breo;
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) && scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3])!=EOF)
	{
		hit=0;
		breo=0;
		for(x=0; x<4; x++)
		{
			if(a[x]==b[x])
				hit++;
			else
			{
				for(y=0; y<4; y++)
				{
					if(x!=y && a[x]==b[y])
						breo++;
				}
			}
		}
		printf("%d %d\n",hit,breo);
	}
	return 0;
}

Measured memory_bytes: 596