akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
using namespace std;
 
int main(){
  
  int n;
  int ans=0;
  int p[21]={0};
    
  cin >> n;
  
  for(int i=1 ; i<=n ; i++){
  	cin >> p[i];
  }
  
  for(int i=2 ; i<=n-1 ; i++){
  	
    if(p[i-1]<p[i] && p[i]<p[i+1]){
     ans++; 
    }else if(p[i-1]>p[i] && p[i]>p[i+1]){
     ans++; 
    }
      
  }
    cout <<ans;
  
  return 0;
}

Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll K;
int A[int(2e5 + 5)];

bool visited[int(2e5 + 5)];
ll num[int(2e5 + 5)], cnt = 0;

int main(){
  scanf("%d%lld", &N, &K);
  for (int i = 1; i <= N; i++) scanf("%d", A + i);

  visited[1] = true;
  int now = A[1];
  while (!visited[now]){

    K--; visited[now] = true;
    if (K == 0){
      cout << now << endl;
      return 0;
    }
    now = A[now];
  }

  while (num[now] == 0){
    cnt++;
    num[now] = cnt;
    now = A[now];
  }
  K %= cnt;
  if (K == 0) K = cnt;

  for (int i = 0; i <= N; i++){
    if (num[i] == K){
      cout << i << endl;
      return 0;
    }
  }


  return 0;
}


Measured memory_bytes: 6184
from collections import defaultdict
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
s = [0 for _ in range(N + 1)]
mp = defaultdict(lambda: 0)
for i, a in enumerate(A):
    s[i + 1] = (s[i] + a) % M
    mp[s[i + 1]] += 1
mp[0] += 1

ans = 0
for value in mp.values():
    if value > 1:
        ans += value * (value - 1) // 2
print(ans)


Measured memory_bytes: 15816
import math

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        ab = math.gcd(a,b)
        if ab == 1:
            ans += k

        else:
            for c in range(1,k+1):
                ans += math.gcd(ab,c)
print(ans)

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

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    string a, b, ans(2*N, ' ');
    cin >> a >> b;
    for (int i = 0; i < N; i++) {
        ans[2*i] = a[i];
        ans[2*i + 1] = b[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(ALL(a));
    int ans = 0;
    rep(i, 2) ans += a[i];
    cout << ans << endl;
    
    return 0;
}

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

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

	vector<int> health;

	for (int i = 0; i < n; i++) {
		int health_i;
		cin >> health_i;
		health.push_back(health_i);
	}

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

	unsigned long long int sum = 0;
	//for (int i = 0; i < health.size(); i++) {
	//	cout << health[i] << endl;
	//}

	if (k_most_times >= n) {
		cout << 0 << endl;
	}

	else {
		for (int i = 0; i < n - k_most_times; i++) {
			sum += health[i];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1400
#include <stdio.h>
#define NIL -1

int n;

int getparent(int i){
    i /= 2;
    if(i < 1) return NIL;
    else return i;
}

int getleft(int i){
    i *= 2;
    if(i > n) return NIL;
    else return i;
}

int getright(int i){
    i = 2*i+1;
    if(i > n) return NIL;
    else return i;
}

int main(){
    int i,parent,left,right,key[250];
    
    scanf("%d",&n);
    for(i=1; i<=n; i++){
    scanf("%d",&key[i]);
    }
        
        for(i=1; i<=n; i++){
      parent = getparent(i);
      left = getleft(i);
      right = getright(i);
     
     printf("node %d: key = %d, ",i,key[i]);
            
            if(parent != NIL)
            printf("parent key = %d, ",key[parent]);
            if(left != NIL)
            printf("left key = %d, ",key[left]);
            if(right != NIL)
            printf("right key = %d, ",key[right]);
             printf("\n");
        }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N,K; cin >> N >> K;
  vector<ll> X(N); rep(i,N) cin >> X[i];
  ll ans = 1e18;
  rep(i,N) {
    if(i+K-1 >= N) continue;
    ll preans;
    ll left = X[i];
    ll right = X[i+K-1];
    // cout << left << " " << right << endl;
    if(right*left >= 0){
      preans = max(abs(left), abs(right));
    }
    else{
      preans = min(abs(left), abs(right)) * 2 + max(abs(left), abs(right));
    }
    ans = min(ans, preans);
  }

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


Measured memory_bytes: 1024
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] xs = new int[3];
			int[] ys = new int[3];
			for (int i = 0; i < 3; i++) {
				int a = scanner.next().charAt(0) - 'A';
				xs[i] = a % 3;
				ys[i] = a / 3;
			}
			double[][][] dp = new double[2][3][3];
			int u = 0;
			dp[u][ys[0]][xs[0]] = 1;
			for (int i = 0; i < n; i++) {
				for (int y = 0; y < 3; y++) {
					for (int x = 0; x < 3; x++) {
						for (int[] m : move) {
							int nx = x + m[0];
							int ny = y + m[1];
							if (nx == xs[2] && ny == ys[2] || nx < 0 || 2 < nx
									|| ny < 0 || 2 < ny)
								dp[1 - u][y][x] += dp[u][y][x] / 4;
							else
								dp[1 - u][ny][nx] += dp[u][y][x] / 4;
						}
						dp[u][y][x] = 0;
					}
				}
				u = 1 - u;
			}
			System.out.printf("%.8f\n", dp[u][ys[1]][xs[1]]);
		}
	}

	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

}

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

int main(){
  int n, x;
  cin >> n >> x;
  int l[n+1];
  l[0] = 0;
  rep(i,n) {
    cin >> l[i+1];
    l[i+1] += l[i];
  }
  int ans = 0;
  rep(i,n+1) {
    if(l[i] <= x) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,cnt=0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string s;
  cin >> n >> m;
  pri(abs((n-2)*(m-2)));
  return 0;
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

ll d[200010];
ll MOD = 1e9+7;

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

	int n,k;cin>>n>>k;


	for(int i=1; i<=n; i++){
		d[i] =i;

		d[i] +=d[i-1];
/*		d[i] %=MOD;*/
	}

	ll sum=0;
	for(int i=k; i<=n; i++){

		ll mx = d[n]-d[n-i];
		ll min = d[i-1];

	/*	cout<<mx<<" "<<min<<" "<<endl;
*/
		sum += mx-min+1;
		sum %=MOD;
	}

	writeln(sum+1);




}




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

const int MAX_A = 300005;

int op (int x, int y) {
    return max(x, y);
}

int e () {
    return 0;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    segtree<int, op, e> dp(MAX_A *2);
    rep(i,n) {
        int x = a.at(i);
        int l = max(0, x - k);
        int r = x + k;
        int now = dp.prod(l, r + 1) + 1;
        dp.set(x, max(dp.get(x), now));
    }

    cout << dp.all_prod() << endl;
    return 0;
}

Measured memory_bytes: 14848
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int d,n;
    cin>>d>>n;
    if(d==0){
    	if(n==100){
    		cout<<101<<endl;
    	}
    else  cout<<n*1<<endl;
    }
    
    else if(d==1){
    	if(n==100){
    		cout<<10100<<endl;
    	}
    else    cout<<n*100<<endl;
    }
    
    else if(d==2){
    	if(n==100){
    		cout<<1010000<<endl;
    	}
    else    cout<<n*100*100<<endl;
    }
	
	
}

Measured memory_bytes: 256
MOD = pow(10, 9) + 7

n, m = map(int, input().split())
slist = list(map(int, input().split()))
tlist = list(map(int, input().split()))

dp = [[1 for _ in range(n+1)] for _ in range(m+1)]
for i, s in enumerate(slist):
  for j, t in enumerate(tlist):
    if s != t:
      dp[j+1][i+1] = ((dp[j+1][i] + dp[j][i+1]) % MOD - dp[j][i]) % MOD
    else:
      #if slist[i] == t and tlist[j] == s:
        dp[j+1][i+1] = (dp[j+1][i] + dp[j][i+1]) % MOD
      #else:
      #  dp[j+1][i+1] = ((dp[j+1][i] + dp[j][i+1]) % MOD - dp[j][i]) % MOD

print(dp[-1][-1])


Measured memory_bytes: 74588
import Data.Maybe
import qualified Data.ByteString.Char8 as B

main = do
  [_,x] <- map read . words <$> getLine
  as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
  print (candies x as)

candies x = fst . foldl (eat x) (0,0)

eat x (acc,rest) a = let n = max 0 (rest+a-x) in (acc+n, a-n)

Measured memory_bytes: 34428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
set<string> sset;
string stmp;
int n;
void solve(){
    cout<<sset.size()<<endl;
}

int main(){
    cin>>n;
    rep(i,n){
        cin>>stmp;
        sset.insert(stmp);
    }

    solve();
    return 0;
}


Measured memory_bytes: 19212
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,k;
    while(cin>>n>>k){
        if(n<=5)cout<<"0"<<endl;
        else if(n<=12)cout<<k/2<<endl;
        else cout<<k<<endl;
    }
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;

string red(string s) {
	stack<char> st;
	for(auto i: s)
		if(i=='(')
			st.push('(');
		else if(i==')' && (st.size()==0 || st.top()==')'))
			st.push(')');
		else
			st.pop();
	string ans="";
	while(st.size())
		ans+=st.top(),st.pop();
	reverse(all(ans));
	return ans;
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
	
	ll n;
	cin>>n;
	vll A(n);
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	ll sum=0;
	for(int i=0;i<n;i++){
		ll x;cin>>x;A[i]-=x;
		A[i]>0?sum+=A[i]:sum+=0;
	}
	cout<<sum<<"\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define ll128 __uint128_t
#define ld long double
#define pll pair <ll, ll>

#define vll vector <ll>
#define vld vector<ld>
#define vpll vector<pll>

#define vvll vector <vll>

#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
#define per(i, a, b) for(ll i = (ll)a - 1; i >= (ll)b; --i)

#define endl "\n"
#define pb push_back
#define pf push_front

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define sorta(v) sort(all(v))
#define sortd(v) sort(rall(v))

#define debug if (1)
#define log(val) debug {cout << "\n" << #val << ": " << val << "\n";}

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(name) freopen(name".in", "r", stdin); freopen(name".out", "w", stdout);
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

#define mod (ll)(1e9 + 7)
#define inf (mod * mod)

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

ostream & operator << (ostream & out, vll & a) {
    for(auto i : a) out << i << " ";
    return out;
}

istream & operator >> (istream & in, vll & a) {
    for(auto &i : a) in >> i;
    return in;
}

const ll N = 4e3 + 5;
ll mn[N][N];

int main() {
    ll n, x;
    cin >> n >> x;
    vll a(n);
    cin >> a;
    vll newa = a;
    for (auto i : newa) a.pb(i);
    n *= 2;

    rep(i, 0, n) {
        ll curMin = 1e18;
        rep(j, i, n) {
            curMin = min(curMin, a[j]);
            mn[i][j] = mn[j][i] = curMin;
        }
    }

    ll ans = 1e18;
    rep(k, 0, n / 2) {
        ll cur = k * x;
        rep(i, n / 2, n) {
            cur += mn[i - k][i];
        }
        ans = min(ans, cur);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 128840
fun main() {

    /**
     * 素因数分解
     * 試し割り法
     */
    fun factorize(number: Long): List<Pair<Long, Int>> {

        var n = number

        val res = mutableListOf<Pair<Long, Int>>()

        for (i in 2..Math.sqrt(n.toDouble()).toLong() + 1) {
            //割り切れなかったら素因数ではない
            if (n % i != 0L) {
                continue
            }
            //割り切れた数だけ++
            var count = 0
            while (n % i == 0L) {
                n /= i
                count++
            }
            res.add(i to count)
        }

        // √n以上の値で素数があったら
        if (n != 1L) {
            res.add(n to 1)
        }
        return res
    }

    val n = readLine()!!.toLong()

    val list = factorize(n)
    var result = 0
    for (item in list) {
        var (_, count) = item
        for (i in 1..count) {
            if (0 <= count - i) {
                count -= i
                result++
            }
        }
    }
    println(result)

}




Measured memory_bytes: 34736
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let n:usize = {
      let line = get_input();
      let mut split = line.split_whitespace();
      split.next().unwrap().parse().unwrap()
    };

    let line = get_input();
    let mut split = line.split_whitespace();

    let mut ans = 200;
    for _i in 0..n {
      let mut a:i32 = split.next().unwrap().parse().unwrap();
      let mut cnt = 0;
      while a % 2 == 0 { a /= 2; cnt += 1; }
      ans = std::cmp::min(ans, cnt);
    }

    println!("{}", ans);
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

lli n, a, b;
lli s;

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

    if(a == 0 && b == 0){
        cout << 0 << endl;
        return 0;
    }
    s = a + b;
    if(s > n){
        if(a < n) cout << a << endl;
        else cout << n << endl;
    }else {
        lli q, r;
        q = n/s;
        r = n-s*q;
        if(a <= r){
            cout << a*q+a << endl;
        }else{
            cout << a*q+r << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);
$A1 = array_map('intval', explode(' ', trim(fgets(STDIN))));
$A2 = array_map('intval', explode(' ', trim(fgets(STDIN))));

$max = 0;
for ($k = 0; $k < $n; ++$k) {
    $tmp_max = 0;
    for ($i = 0; $i < $k; ++$i) {
        $tmp_max += $A1[$i];
    }
    $tmp_max += $A1[$k];
    $tmp_max += $A2[$k];
    for ($i = $k + 1; $i < $n; ++$i) {
        $tmp_max += $A2[$i];
    }

    $max = max($max, $tmp_max);
}
echo $max;


Measured memory_bytes: 16152
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    ll N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];
    vl x(N);
    REP(i, N) x[0] += (i % 2 == 0) ? A[i] : -A[i];
    for(int i = 1; i < N; i++) x[i] = 2*(A[i-1] - x[i-1]/2);
    REP(i, N) cout << x[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
        int[] ans = new int[n+1];
        for(int a = 1; a <= 100; a++){
            for(int b = 1; b <= 100; b++){
                for(int c = 1; c <= 100; c++){
                    int val = a*a + b*b + c*c + a*b + a*c + c*b;
                    if(val <= n){
                        ans[val]++;
                    }
                }
            }
        }

        for(int i = 1; i <= n; i++){
            System.out.println(ans[i]);
        }
	}
}

Measured memory_bytes: 38768
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	map<string,int> M={{"SUN",7},{"MON",6},{"TUE",5},{"WED",4},{"THU",3},{"FRI",2},{"SAT",1}};
	string N=in<string>();
	
	out(M[N]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);

  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }

  long long sumA = 0;
  long long minA = 0;
  for(int i=0;i<n;i++){
    sumA += a.at(i);
    if(i%2==0){
      if(sumA <= 0){
        minA += abs(sumA)+1;
        sumA += abs(sumA)+1;
      }
    }else{
      if(sumA >= 0){
        minA += abs(sumA)+1;
        sumA -= abs(sumA)+1;
      }
    }
  }

  long long sumB = 0;
  long long minB = 0;
  for(int i=0;i<n;i++){
    sumB += a.at(i);
    if(i%2!=0){
      if(sumB <= 0){
        minB += abs(sumB)+1;
        sumB += abs(sumB)+1;
      }
    }else{
      if(sumB >= 0){
        minB += abs(sumB)+1;
        sumB -= abs(sumB)+1;
      }
    }
  }
  
  cout << min(minA,minB) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

const long long int INF = LLONG_MAX;

int main() {
    int n;
    cin >> n;
    vector <int64_t> a(n), s(n + 1, 0);
    vector <vector <int64_t> > dp(n, vector <int64_t> (n, 0));

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

    // dp[i][j] - minimum cost from range i-j

    for (int i = 0; i < n - 1; i++) {
        dp[i][i + 1] = a[i] + a[i + 1];
    }

    int64_t nr, minimum;
    for (int step = 2; step < n; step++) {
        for (int i = 0; i + step < n; i++) {
            minimum = INF;
            for (int k = i; k < i + step; k++) {
                nr = dp[i][k] + dp[k + 1][i + step] + s[i + step + 1] - s[i];     
                if (minimum > nr)
                    minimum = nr;
            }
            dp[i][i + step] = minimum;
        }
    }

    cout << dp[0][n - 1] << '\n';
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950



int main() {
	std::string s; std::cin >> s;
	std::sort(s.begin(), s.end());
	for (int i = 0; i < s.size() - 1; ++i) {
		if (s[i] == s[i + 1]) {
			std::cout << "no" << std::endl;
			return 0;
		}
	}
	std::cout << "yes" << std::endl;

	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string s;
    cin>>s;
    for(char i='a';i<'z'+1;i++){
        bool flag = true;
        rep(j,s.length()){
            if(s[j]==i)flag = false;
        }
        if(flag){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, h, w;
    cin >> n >> h >> w;

    ll ans = 0;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if(a >= h && b >= w) {
            ans++;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main(void) {
	int N;        //カードの枚数
	int a[ 100 ]; //カードに書いてある数
	int alice = 0;//Alice
	int bob = 0;  //Bob
	cin >> N;
	for (int i = 0;i < N;i++)
		 cin >> a[ i ];
	sort(a,a + N,greater<int>());
	for (int i = 0;i < N;i++) {
		if (i % 2 == 0) alice += a[ i ];
		if (i % 2 == 1) bob += a[ i ];
	}
	cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
int main(int argc, const char * argv[]) {
    int i,sum[26]={};
    char sent;
    while(scanf("%c",&sent)!=EOF){
        if(isupper(sent)){
            sent = tolower(sent);
        }
        sum[sent-'a']++;
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",i+'a',sum[i]);
    }
        return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < (r); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;

const ll mod = 1000000007;

int main(){
	int h, w;
  	cin >> h >> w;
  	char a[1005][1005];
  	rep(i, 1, h+1)rep(j, 1, w+1) cin >> a[i][j];
  
  	ll dp[1005][1005];
	dp[1][1] = 1;
  
	rep(i, 1, h+1)rep(j, 1, w+1){
    	if(!(i == 1 && j == 1)){
        	if(a[i][j] == '#') dp[i][j] = 0;
          	else dp[i][j] = (dp[i-1][j]+dp[i][j-1]) % mod;
        }
    }
  
	cout << dp[h][w] << endl;
}

Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
    int n,x[100],y[100];
    double p1=0,p2=0,p3=0,pm,pmax=0;

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

    for(int i=0; i<n; i++)p1 += 1.0*fabs(x[i]-y[i]);
    
    for(int i=0; i<n; i++)p2 += 1.0*pow(x[i]-y[i],2);
    p2 = sqrt(p2);

    for(int i=0; i<n; i++)p3 += 1.0*pow(fabs(x[i]-y[i]),3);
    p3 = pow(p3,1.0/3.0);

    for(int i=0; i<n; i++){
        pm = 1.0*fabs(x[i]-y[i]);
    	if(pm-pmax > 0) pmax = pm;
    }

    printf("%f\n%f\n%f\n%f\n",p1,p2,p3,pmax);
    //printf("test %f\n",pow(8,1.0/3.0));

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))
#define swap(type, a, b) { type temp = a; a = b; b = temp; }

int N, M;
int * data;

void init() {
  // child: parent's index
  // root: -size
  data = array(N, int);

  rep(i, N) {
    // at first, all data is root and size is -1
    data[i] = -1;
  }
}

int find(int x) {
  if (data[x] < 0) {
    return x;
  }

  return data[x] = find(data[x]);
}

int same(int x, int y) {
  return find(x) == find(y);
}

int unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) {
    return 0;
  }
  // becasue data has minus size, reverse the inequality sign
  if (data[x] > data[y]) {
    swap(int, x, y);
  }
  data[x] += data[y];
  data[y] = x;
  return 1;
}

int size(int x) {
  return -data[find(x)];
}

int main() {
  scanf("%d%d", &N, &M);
  // initialize
  init();

  rep(i, M) {
    int A, B;
    scanf("%d%d", &A, &B);
    A -= 1;
    B -= 1;
    unite(A, B);
  }

  /* int ans = 0; */
  /* rep(i, N - 1) { */
  /*   if (same(i, i + 1)) { */
  /*   } else { */
  /*     unite(i, i + 1); */
  /*     ans += 1; */
  /*   } */
  /* } */

  int cnt = 0;

  rep(i, N) {
    if (find(i) == i) {
      cnt += 1;
    }
  }

  printf("%d\n", cnt - 1);

  free(data);

  return 0;
}


Measured memory_bytes: 1764
N=gets.to_i
a = gets.split.map(&:to_i)
s = Array.new(N+1, 0)
N.times do |i|
  s[i+1] = s[i] + a[i]
end

ans = 10**10
(0...(N-1)).each do |i|
  x = s[i+1] - s[0]
  y = s[N] - s[i+1]
  ans = [ans, (x-y).abs].min
end

puts ans

Measured memory_bytes: 20868
import sys
import fractions
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
a = []
b = []
c = []
for i in range(n):
    a1, b1, c1 = MAP()
    a.append(a1)
    b.append(b1)
    c.append(c1)

dp0 = [0]*3
dp1 = [0]*3
dps = [dp0, dp1]
dp = [0]*n
abc = [a, b, c]

dps[0][0] = a[0]
dps[0][1] = b[0]
dps[0][2] = c[0]

dp[0] = max(dps[0])

for i in range(1,n):
    for j in range(3):
        dps[i%2][j] = abc[j][i] + max(dps[(i-1)%2][(j+1)%3], dps[(i-1)%2][(j+2)%3])
    dp[i] = max(dps[i%2])

print(dp[n-1])


Measured memory_bytes: 84056
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 212345;

int n, m, k;
int s[MAXN];

int root;

struct no {
    int nxt[30];
    int f[30];
    
    int next(char c){
        if(nxt[c-'a'] == -1)
            return -1;
        return nxt[c-'a'];
    }

    no() {
        for(int a=0;a<30;a++){
            nxt[a] = -1;
            f[a] = 0;
        }
    }
};

vector<no> trie;

inline int create(int u, char c){
    if(trie[u].next(c) == -1){
        trie[u].nxt[c-'a'] = trie.size();
        trie.push_back(no()); 
    }
    return trie[u].next(c);
}

inline void add(string s){ // adds string s to trie
     int u = root; 
     int freq[30];
     memset(freq, 0, sizeof(freq));
     for(char c: s)
         freq[c-'a']++;
     for(int a=0;a<30;a++)
        trie[u].f[a] += (freq[a] > 0);
     for(char c: s){
        u = create(u, c);
        freq[c-'a']--;
        for(int a=0;a<30;a++){
            trie[u].f[a] += (freq[a] > 0);
        }
     }
}

inline void init(){
    trie.clear();
    trie.push_back(no());
    root = 0;
}


void print() { // prints the whole trie
    for(int i=0;i<trie.size();i++){
        printf("i %d nxt: ", i); 
        for(int a=0;a<30;a++){
            if(trie[i].nxt[a] == -1) continue;
            printf("(%c %d) ", 'a'+a, trie[i].nxt[a]); 
        }
        puts("");
    }
}


inline int query(string s){
    int u = root; 
    for(int a=0;a+1<s.size();a++){
        u = trie[u].next(s[a]);
        if(u == -1)
            return 0;
    }
    return trie[u].f[s.back()-'a'];
}

char pal[1000006];

int main (){
    init();
	scanf("%d", &n);
    vector<int> ind;
    vector<string> s;
	for(int a=0;a<n;a++){
        scanf(" %s", pal);
        int sz= strlen(pal);
        reverse(pal, pal+sz);
        s.pb(pal);
        ind.pb(a);
	}
    sort(ind.begin(), ind.end(), [&](int a, int b) -> bool { return (s[a].size() > s[b].size()); });
    ll ans = 0;
    for(int aa=0;aa<n;aa++){
        int i = ind[aa];
        ans += query(s[i]);
        add(s[i]);
//print();
    }
    printf("%lld\n", ans);
}



Measured memory_bytes: 257844
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int min=0;
	VI p(3);
	rep(i, 3) cin >> p[i];

	sort(all(p));

	cout << p[0] + p[1] << endl;


}

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

  return 0;
}


Measured memory_bytes: 3640
#include<cstdio>

int main(void){
	int sum_p = 0, sum_q = 0, cnt = 0;

	while( true ){
		int p, q;

		if( 2 != scanf("%d,%d", &p, &q) ){
			break;
		}
		cnt++;
		sum_p += p * q;
		sum_q += q;
	}

	printf("%d\n%.0f\n", sum_p, (double)sum_q / cnt + 0.5);
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];

    ll ans = INF;
    rep(i, N) {
        if (i + K - 1 < N) {
            ll r = X[i + K - 1];
            ll l = X[i];
            ans = min(ans, min(abs(r) + abs(r - l), abs(l) + abs(r - l)));
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 1024
s = int(input())
k = set()
k.add(s)
a = [s]
a1 = s
i = 2
while True:
    if a[-1] % 2 == 0:
        #k.add(a[-1] // 2)
        a.append(a[-1]//2)

    else:
        #k.add(3 * a[-1] + 1)
        a.append(3*a[-1] + 1)

    if a[-1] in k:
        print(i)
        exit()
    else:
        k.add(a[-1])
        i += 1

Measured memory_bytes: 3064
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
ans = INF
for d in range(1,int(math.sqrt(N))+1):
    if N%d == 0:
        ans = min(ans,d-1+N//d-1)

print(ans)


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  ll n,ans=0;
  cin>>n;
  vector<ll> a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  rep(i,n){
    if((a[i]+ans)%b[i]!=0){
      ans+=b[i]-((a[i]+ans)%b[i]);
    }
  }
  cout<<ans<<endl;
}
///////////////////////////









Measured memory_bytes: 1792
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
const int maxn=1e5+5;
inline int read(){
	int n=0,f=1;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if (c=='-') c=getchar(),f=-1;
	for(;c>='0'&&c<='9';c=getchar()) n=n*10+c-48;
	return n*f;
}
int i,j,n,k[maxn],ne[maxn<<1],g[maxn<<1],num,f[maxn];
void add(int x,int y){
	ne[++num]=k[x],k[x]=num,g[num]=y; 
}
void dfs(int x,int y){
	int i,s=0,now=0;
	for(i=k[x];i;i=ne[i]){
		int go=g[i];
		if (go!=y){
			dfs(go,x);
			now=max(now,(s&f[go]));
			s|=f[go];
		}
	}
	if (!now) {
		fo(i,0,20) if (!(s&(1<<i))) break;
		f[x]=(1<<i)|((s>>i)<<i); 
	}else{
		fo(i,0,20) if (!(s&(1<<i))&&((1<<i)>now)) break;
		f[x]=(1<<i)|((s>>i)<<i);
	} 
}
int main(){
	n=read();
	fo(i,1,n-1){
		int x=read(),y=read();
		add(x,y),add(y,x);
	}
	dfs(1,0);
	fd(i,20,0) if (f[1]&(1<<i)) break;
	printf("%d\n",i);
}

Measured memory_bytes: 8320
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
 
int a[100000];
 
int main() {
	int N; cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i];
 
	map<int, int> mp;
	for (int i = 0; i < N; i++)
		mp[a[i]]++;
 
	int ans = 0;
	for (auto p: mp) {
		int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}
	cout << ans << endl;
}

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

double a, b, h, m;
double kakudo;
double ans;
double pi =  3.141592653589793238;


int main(){
    cin >> a >> b >> h >> m;
    kakudo = abs(30 * h - 5.5 * m);
    if(kakudo >= 180) kakudo = 360 - kakudo;
    ans = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(pi * kakudo / 180);
    ans = sqrt(ans);
    cout << fixed << setprecision(13) << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n;cin>>n;
  vector<ll> a(n);
  rep(i,n){
      cin>>a[i];
  }
  map<ll,ll> table;
  rep(i,n){
    if(table.find(a[i])!=table.end()){
      table[a[i]]++;
    }else{
      table[a[i]]=1;
    }
  }
  ll sm=0;
  for(auto it=table.begin();it!=table.end();++it){
    ll val=it->second;
    sm+=val*(val-1)/2;
  }
  rep(i,n){
    ll val=table[a[i]];
    ll ans=sm-val*(val-1)/2+(val-1)*(val-2)/2;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 11008
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let _: usize = util::get();
    let a: Vec<usize> = util::gets();

    println!("{}", a.iter().max().unwrap() - a.iter().min().unwrap());
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] ln = line.split(" ");
        BigDecimal a = new BigDecimal(new Integer(ln[0]));
        BigDecimal b = new BigDecimal(new Integer(ln[1]));
        System.out.println(a.divideToIntegralValue(b).toPlainString() + " " + a.remainder(b).toPlainString() + " " + a.divide(b,10,RoundingMode.HALF_UP).toPlainString());
    }
}

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

int main() {
	ll N; cin >> N;
	char S;
	rep(i, 0, N) {
		cin >> S;
		if (S == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
void main() {
	("A" ~ rs[8] ~ "C").writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<n; i++)
#define REP1(i,n) for(int i=1; i<n; i++)
#define IREP(i,n) for(int i=n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(c) (c).begin(), (c).end() 
#define INF INT_MAX
using namespace std;

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) {}
	bool operator < (const Edge &e) const {
		return weight != e.weight ? weight > e.weight :
			src != e.src ? src < e.src : dst < e.dst;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev) {
	int n = g.size();
	dist.assign(n,INF);
	dist[s] = 0;
	prev.assign(n,-1);
	priority_queue<Edge> Q;
	for(Q.push(Edge(-2,s,0)); !Q.empty(); ) {
		Edge e = Q.top();
		Q.pop();
		if(prev[e.dst] != -1) continue;
		prev[e.dst] = e.src;
		FOR(f,g[e.dst]) {
			if(dist[f->dst] > e.weight+f->weight) {
				dist[f->dst] = e.weight+f->weight;
				Q.push(Edge(f->src, f->dst, e.weight+f->weight));
			}
		}
	}
}

int main() {
	int V, E, r;
	cin >> V >> E >> r;
	Graph graph(V);
	REP(ie,E) {
		int s, t, d;
		cin >> s >> t >> d;
		graph.at(s).push_back(Edge(s,t,d));
	}
	vector<Weight> dist(V);
	vector<int> prev(V);
	shortestPath(graph, r, dist, prev);
	for(vector<Weight>::iterator it = dist.begin(); it != dist.end(); it++) {
		if(*it != INF) cout << *it << endl;
		else cout << "INF" << endl;
	}
	return 0;
}

Measured memory_bytes: 14664
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,k;
    cin>>n>>k;
    vector<int> a(n+1),b(n+1);
    repi(i,1,n+1) cin>>a[i];
    int cnt=0,i=1;
    while(cnt<k){
        if(b[i]==0) b[i]=cnt;
        else{
            b[i]=cnt-b[i];
            k=(k-cnt)%b[i];
            break;
        }
        if(cnt==k-1){
            cout<<a[i];
            return 0;
        }
        i=a[i];
        cnt++;
    }
    rep(j,k) i=a[i];
    cout<<i;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	FOR(i,0,n)cin >> h[i];
	sort(ALL(h));
	int ans = INF;
	FOR(i,0,n-k+1){
		ans = min(ans, h[i+k-1] - h[i]);
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    int size=s.size();
    int ans=0;
    rep(i,size/2){
        if(s[i]!=s[size-i-1])ans++;
    }
    cout<<ans<<endl;
}


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

int main(void){
    string s;
    cin >> s;
    int q;
    cin >> q;
    int rev = false;
    string a = "";
    string b = "";
    rep(_,q){
        int t;
        cin >> t;
        if(t == 1){
            rev = !rev;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if((f-1)^rev){
                b += c;
            }else{
                a += c;
            }
        }
    }
    if(rev){
        reverse(all(s));
        reverse(all(b));
        cout << b << s << a << endl;
    }else{
        reverse(all(a));
        cout << a << s << b << endl;
    }
}


Measured memory_bytes: 1088