akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef vector<int> vi;
typedef long long int ll;
vector<vector<int>> adj;

class B {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n; in>>n;
        set<int> s;
        f(i, n){
            int x; in>>x;
            s.insert(x);
        }
        out<<s.size();

	}
    void inG(int m, istream& in){ int u,v; adj = vector<vi>(200005);f(i, m){ in>>u>>v; adj[u].push_back(v); adj[v].push_back(u); }}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	B solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

long long N,M;
long long ans=0;

int main(){
    cin>>N>>M;
    
    
    if(N==1&&M==1)ans=1;
    else if(N==1||M==1)ans=N*M-2;
    else{
        ans=(N-2)*(M-2);
    }
    
    cout<<ans<<endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	double array[15];
	double sum=0;
	while(cin>>array[0]){
		for(int i=1;i<=9;i++){
			if(i%2==1){
				array[i]=array[i-1]*2;
			}else{
				array[i]=array[i-1]/3;
			}
		}
		for(int i=0;i<=9;i++){
			sum+=array[i];
		}
		cout.precision(10);
		cout<<sum<<endl;
		sum=0;
	}
}

Measured memory_bytes: 1276
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;

	for (int i = 0; i < n1; ++i) L[i] = A[left + i];
	for (int i = 0; i < n2; ++i) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	int i = 0, j = 0;
	
	for (int k = left; k < right; ++k) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[], int n, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main() {
	int A[MAX], n;
	cnt = 0;

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

	mergeSort(A, n, 0, n);

	for (int i = 0; i < n; ++i) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;

	cout << cnt << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  ll result = 1000;
  rep(i,N-1) if (A[i+1]>A[i]) result = result%A[i] + result/A[i]*A[i+1];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,X,Y;
    cin >> N >> X >> Y;
    vector<vector<int>> tree(N);
    REP(i, N-1){
        tree[i].pb(i+1);
        tree[i+1].pb(i);
    }
    X--;Y--;
    tree[X].pb(Y);
    tree[Y].pb(X);

    map<int, int> ans;
    REP(i, N){
        vector<int> ok(N, -1);
        queue<int> q;
        q.push(i);
        ok[i] = 0;
        while(!q.empty()){
            auto f = q.front();q.pop();
            for(auto&& c : tree[f]){
                if(ok[c]==-1){
                    ok[c] = ok[f] + 1;
                    q.push(c);
                }
            }
        }
        for(auto&& oki : ok){
            ans[oki]++;
        }
    }
    Rep(i, 1 ,N){
        pr(ans[i]/2);
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;

int main() {
  string S;
  cin>>S;
  ll n=(ll)S.size();
  int dp[n+1ll][2];
  rep(i,n+1ll){dp[i][0]=0ll;dp[i][1]=0ll;}
  dp[0][1]=1ll;dp[0][0]=0ll;
  rep(i,n){
    dp[i+1][0]=min(dp[i][0]+(S[i]-'0'),dp[i][1]+10-(S[i]-'0'));
    if(S[i]!='9'){dp[i+1][1]=min(dp[i][0]+1+(S[i]-'0'),dp[i][1]+9-(S[i]-'0'));}
    else{dp[i+1][1]=dp[i][1]+9-(S[i]-'0');}
  }
  
  cout<<min(dp[n][0],dp[n][1]+1)<<endl;
}


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

int main() {
  double D, T, S;
  cin >> D >> T >> S;
  
  double x = D/S;
  
  if(T>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




Measured memory_bytes: 3724
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n,a[SIZE];
  ll sum = 0;
  
  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%d",a+i);
    sum += a[i];
  }

  ll ans = LLINF;
  ll sum_i = 0;
  
  for(int i=0;i<n-1;i++){
    sum_i += a[i];

    ans = min(ans, abs(sum_i - (sum - sum_i)));
  }

  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;cin>>n>>m;
    vector<int> edge[n];
    rep(i,m)
    {
        int a,b;cin>>a>>b;
        a--;b--;
        edge[a].push_back(b);
    }
    double dp[n];
    rep(i,n) dp[i] = 0.0;
    // dp[n-1] = 0;
    // dp[n-2] = 1;
    for (int i = n-2; i>=0;i--)
    {
        double tmp_num = edge[i].size();
        // cout <<"tmpnum " << tmp_num << endl;
        for (auto iter = edge[i].begin();iter!=edge[i].end();iter++)
        {
            dp[i] += dp[*iter]/tmp_num;
        }
        dp[i]+=1;
    }

    double ans = dp[0];
    rep(j,n-1)
    {
        if (edge[j].size()==1) continue;
        double dp2[n];
        rep(i,n) dp2[i] = 0.0;
        auto max_iter = edge[j].begin();
        double max_num = dp[*max_iter];
        // cout << "begin: " << *max_iter << endl;
        for (auto iter = edge[j].begin();iter!=edge[j].end();iter++)
        {
            if (max_num < dp[*iter])
            {
                max_num = dp[*iter];
                // cout << max_num << endl;
                max_iter = iter;
            }
        }
        // cout << endl;
        // cout << j << " " << max_num << endl;

        for (int i=n-2;i>=0;i--)
        {
            double tmp_num = edge[i].size();
            if (i==j) tmp_num--;
            for (auto iter = edge[i].begin();iter!=edge[i].end();iter++)
            {
                if (i!=j || iter!=max_iter)
                {
                    dp2[i] += dp2[*iter]/tmp_num;
                }
            }
            dp2[i]+=1;
        }
        ans = min(ans, dp2[0]);
        // cout << dp2[0] << endl;
    }

    cout << fixed << setprecision(10) << ans << endl;
}


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

int main () {
  int s;
  cin >> s;
  set<int> st;
  while (st.count(s) == 0) {
    st.insert(s);
    if (s % 2 == 0)
      s /= 2;
    else
      s = 3*s + 1;
  }
  cout << st.size() + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    long double A, B;
    cin >> A >> B;
    long double H, M;
    cin >> H >> M;
    long double theta_m = PI * M / 30.0;
    long double theta_h = PI * H / 6.0 + M * PI / 360.0;
    long double x;
    x = pow(A * A + B * B - 2.0 * A * B * cos(abs(theta_h - theta_m)), 0.5);
    cout << setprecision(20) << x << endl;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back




int main(){
  

  ll n;
  cin>>n;
  
  vector<ll> data(n);
  rep(i,n){
    ll tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }
  
  vector<ll> cnt(200001);
  
  rep(i,n){
    cnt.at(data.at(i))++;
  }
  
  ll answer=0;
  
  rep(i,200001){
    ll tmp=0;
    if (cnt.at(i)>=2){
      tmp=(cnt.at(i))*(cnt.at(i)-1)/2;
    }
    answer+=tmp;
  }
  
  rep(i,n){
    ll answeri=answer;
    ll x=cnt.at(data.at(i));
    if (x>=2){  
      answeri=answeri-(x*(x-1)/2)+((x-1)*(x-2)/2);
    }
    cout<<answeri<<endl;
  }
  

}




















Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

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

vector<pii> v;
bool compare(pii A, pii B)
{
    return A.first < B.first;
}

int main()
{
    int n, m, a, b;

    cin>>n>>m;

    for(int i = 0; i < n; i++){
        cin>>a>>b;
        v.push_back(make_pair(a, b));
    }

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

    ll ans = 0;
    for(int i = 0; i < v.size(); i++){
        int temp = min(m, v[i].second);
        ans += (temp * 1LL * v[i].first);
        m -= temp;
        if(m <= 0)
            break;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main(void){
    
    int a,b;
    cin >>a>>b;
    
    if(a < b){
        cout <<"a < b"<<endl;
    }else if(a > b){
        cout <<"a > b"<<endl;
    }else{
        cout <<"a == b"<<endl;
    }
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

//set many funcs template
//Ver.20181228
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

// 1234321
// 1234567

int is_kb (char *str, int64 size)
{
  int i;
  int j;
  int limit = size/2;

//  printf("size=%d\n", size); // for debug

  j = size - 1;
  for (i=0; i<limit; i++) {
//    printf("%c %c\n", str[i], str[j]); // for debug
    if (str[i] != str[j]) {
      return 0;
    }
    j--;
  }
  return 1;
}

int main()
{
  char *str;
  int64 size;
  int  first,second;

  str = get_SN(100, &size);

//  printf("str=%s size=%d\n", str, size);// for debug

  if (!is_kb(str, size)) {
    printf("No");
    return 0;
  }

  first  = is_kb(str, ((size - 1)/2));
  second = is_kb((str + ((size+3)/2) - 1), (size - ((size+3)/2) + 1));

  if (first && second) {
    printf("Yes");
  } else {
    printf("No");
  }

  return 0;
}



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

using namespace std;
using ll = long long;

const int mx = 3000 + 9;

int R, C, K;
ll g[mx][mx];
ll dp[mx][mx][4];

ll solve(int i, int j, int k) {
    if (i > R) return 0;
    if (j > C) return 0;
    ll& ans = dp[i][j][k];
    if (ans != -1) return ans;

    ans = 0;
    if (k > 0) {
        ans = max(ans, g[i][j] + solve(i, j + 1, k - 1));
        ans = max(ans, g[i][j] + solve(i + 1, j, 3));
    }

    ans = max(ans, solve(i, j + 1, k));
    ans = max(ans, solve(i + 1, j, 3));
    
    return ans;
}

int main() {
    scanf("%d %d %d", &R, &C, &K);
    for (int i = 0; i < K; i++) {
        int r, c; ll v;
        scanf("%d %d %lld", &r, &c, &v);
        g[r][c] = v;
    }

    memset(dp, -1, sizeof dp);
    ll ans = solve(1, 1, 3);
    printf("%lld\n", ans);
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

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

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll ans=0;
	ll n, k; cin>>n>>k;
	vector<pll> dt(n), table;
	rep(i, n) cin>>dt[i].se>>dt[i].fi;
	sort(rall(dt));
	vector<bool> use(n+1, false);
	rep(i, n){
		if (use[dt[i].se]==false){
			table.pb(dt[i]);
			use[dt[i].se] = true;
			dt[i].se = dt[i].fi = 0;
		}
	}
	sort(rall(dt));
	dt.insert(dt.begin(), mp(0ll,0ll));
	rep(i, dt.size()-1) dt[i+1].fi += dt[i].fi;
	rep(i, table.size()-1) table[i+1].fi += table[i].fi;
	for(ll i=1; i<=min(k, (ll)table.size()); i++){
		ans = max(ans, table[i-1].fi+dt[k-i].fi+i*i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6128
# -*- coding: utf-8 -*-

n, x, m = map(int, input().split())

a_list = [x]
a = x
i = 1
while (i<n and i < m+1):
    a = (a*a) % m
    a_list.append(a)
    i += 1
    
#print(i)
#print(a_list)
    
if i == n:
  ans = sum(a_list)
else:
    b = a_list.index(a)
    sum1 = sum(a_list[:b+1])
    sum2 = sum(a_list[b+1:i])
    blen = i-b-1
    repeat = (n-b-1) // blen
    amari = (n-b-1) % blen
    sum3 = 0
    if amari != 0:
    	sum3 = sum(a_list[b+1:b+amari+1])
    ans = sum1 + sum2*repeat + sum3
    #print(blen)
    #print(amari)
    #print(sum1, sum2, repeat, sum3)

print(ans)

Measured memory_bytes: 13568
#line 1 "../lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  vector<pair<double, double>> xy(n);
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    xy[i] = {x, y};
  }

  sort(ALL(xy));

  int fn = 1;
  FOR(i, 1, n + 1) { fn *= i; }
  double sum = 0;
  do {
    REP(i, n - 1) {
      sum += sqrt((xy[i + 1].first - xy[i].first) * (xy[i + 1].first - xy[i].first) +
                  (xy[i + 1].second - xy[i].second) * (xy[i + 1].second - xy[i].second));
    }

  } while (next_permutation(ALL(xy)));

  coutd(10) << sum / fn << endl;

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    cout << s.at(i);
    if(i==3){
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3544
#include <iostream>
using namespace std;
int d[10000],e[10000];
int main(void){
	for (;;){
		long a,b,c,g=0;
		cin>>a>>b;
		if (a==0&&b==0) break;
		long f[501]={0};
		for (c=0;c<b;c++){
			cin>>d[c]>>e[c];
				if (d[c]==1)f[e[c]]=2;
		}
		for(c=0;c<b;c++){
			if(f[d[c]]==2&&f[e[c]]==0)f[e[c]]=3;
			if(f[e[c]]==2&&f[d[c]]==0)f[d[c]]=3;
		}
		for (c=2;c<=a;c++){
			if (f[c]!=0)g++;
		}
		cout<<g<<endl;
	}
	return 0;
}
	
			

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

using namespace std;

#define EPS 1e-10

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

struct Point {
	double x, y;

	Point() {}
	Point(double x, double y) :x(x), y(y) {}

	Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
	Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
	Point operator*(const double& k) const { return Point(x * k, y * k); }
	Point operator/(const double& k) const { return Point(x / k, y / k); }

	friend istream& operator>>(istream& is, Point& p) {
		is >> p.x >> p.y;
		return is;
	}

	bool operator==(const Point& p) const { return (fabs(x - p.x) < EPS && fabs(y - p.y) < EPS); }
	bool operator<(const Point& p) const { return (x != p.x ? x < p.x : y < p.y); }

	double norm() { return x * x + y * y; }
	double abs() { return sqrt(norm()); }
};

typedef Point Vector;

double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }

int ccw(Point p0, Point p1, Point p2) {
	Vector a = p1 - p0, b = p2 - p0;
	if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS) return CLOCKWISE;
	if (dot(a, b) < -EPS) return ONLINE_BACK;
	if (a.norm() < b.norm()) return ONLINE_FRONT;
	return ON_SEGMENT;
}

bool ok(Point a, Point b, Point c, Point p) {
	return (signbit(cross(b - a, p - b)) == signbit(cross(c - b, p - c)) &&
		signbit(cross(c - b, p - c)) == signbit(cross(a - c, p - a)));
}

int main() {
	int n; cin >> n;
	vector<Point> points(n);
	for (int i = 0; i < n; ++i) {
		cin >> points[i];
		points[i] = points[i] + points[i] / 9999;
	}
	int q; cin >> q;
	while (q--) {
		Point a; cin >> a;
		int l = 1, r = n - 1;
		while (l != r - 1) {
			int mid = (l + r) / 2;
			if (ccw(points[0], points[mid], a) == CLOCKWISE) r = mid;
			else l = mid;
		}
		if (ok(points[0], points[l], points[r], a)) cout << 1 << endl;
		else cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 3404
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M 100000
typedef struct node *link;
struct node{long int v; link next; link back;};
link NEW(long int v){
	link x = malloc(sizeof(*x));
	x->v = v;
	return x;
}

void traverse(link head,link end){

	link t;
	t = head->next;

	while(t != end){
		if(t->next==end) printf("%ld",t->v);
		else printf("%ld ",t->v);
		t = t->next;
	}

	printf("\n");

	return;

}

void delete_x(link x){

	x->back->next = x->next;
	x->next->back = x->back;

	return;
}

void insert(link x, link ins){

	ins->next = x->next;
	ins->back = x;
	x->next->back = ins;
	x->next = ins;

	return;
}

link search(link head, link end, long int v){
	link t =head->next;
	while(t != end){
		if(t->v==v){
			return t;
		}
		t = t->next;
	}

	return end;
}

int main(void){

	link head,end,t,a[M];
	head = NEW(-1);
	end = NEW(-1);
	head->next=end;
	end->back=head;

	char com[11];
	int i,j,n;
	long int v;
	scanf("%d",&n);


	for(i=0;i<n;i++){

		scanf("%s",com);
	
	if(strcmp(com,"insert")==0){	
	scanf("%ld",&v);
	a[j] = NEW(v);
	insert(head,a[j]);
	j++;
	}
	
	if(strcmp(com,"delete")==0){
	scanf("%ld",&v);
	t = search(head,end,v);
	if(t!=end) delete_x(t);
	}

	if(strcmp(com,"deleteFirst")==0){
	delete_x(head->next);
	}
	if(strcmp(com,"deleteLast")==0){
	delete_x(end->back);
	}

	}

	traverse(head,end);

	return 0;
}

Measured memory_bytes: 36048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio  ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0)
const ll mod = 10e9 + 7;

int main()
{
  fastio;
  string rain;
  cin>>rain;
  if(rain=="RRS"||rain=="SRR")
  {
    cout<<2<<endl;
  }
  else if(rain=="SSS")
  {
    cout<<0<<endl;
  }
  else if(rain=="RRR")
  {
    cout<<3<<endl;
  }
  else
  {
    cout<<1<<endl;
  }

  
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
int main()
{
    lg n;
    cin>>n;
    lg ans=0;
    if(n%1000!=0) ans = 1000 - n%1000;


    cout<<ans<<endl;
}


Measured memory_bytes: 3516
# coding: utf-8
"""
import codecs
import sys

sys.stdout = codecs.getwriter("shift_jis")(sys.stdout) # ??????
sys.stdin = codecs.getreader("shift_jis")(sys.stdin) # ??\???

# ??\??¬?????????print??????????????´?????? print(u'?????????') ??¨??????
# ??\??¬?????????input??? input(u'?????????') ??§OK
# ??°?¢???????????????????????????´??????6,7???????????????????????¢??????
"""

s = raw_input()
p = raw_input()

#s = "abaabbaabbaaaaaabbaabba"
#p = "aabbaabaabb"

cnt = s.count(p[0]) #????§?????£?????????°
flag = 0
if cnt == -1: #p???????????????????????¨?????????
	print("No")
else: #????§?????£?????????¨??????
	start_search = 0 #????´¢?????????????§???????
	while cnt > 0:
		index = s.find(p[0], start_search) #????§????????????????
		ans = 1
		for i in range(len(p)):
			if index + i >= len(s): #????°?????????????????????´??????????????????????????????????????????
				j = i - len(s)
			else:
				j = i
			if s[index + j] != p[i]: #1????????§????????£????????????????????§??¢?´¢??????
				ans = 0
				break
		if ans == 1:
			print("Yes")
			flag = 1
			break
		start_search = index + 1
		#print(start_search)
		cnt -= 1
	if flag == 0:
		print("No")

Measured memory_bytes: 6480
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

//-------------------------------------------------------------------
#define INF 1000000009
#define MAX_V 1000000
#define MAX_E 1000000
struct edge{ll from, to, cost;};
edge es[MAX_E];
ll d[MAX_V];
ll V, E;
ll bellman(ll s){
  for(int i=0;i<V;i++) d[i] = INF;
  d[s] = 0;
  ll num=0;
  while(true){
    bool update = false;
    for(int i=0;i<E;i++){
      num++;
      edge e = es[i];
      if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
        if(num>V*E) d[e.to] = -1000000000;
        else d[e.to] = d[e.from]+e.cost;
        update = true;
      }
    }
    if(!update) break;
    if(num>3*V*E){
      if(d[V]<=-1000000000)return 1;
      else return 0;
    }
  }
  return 0;
}
//------------------------------------------------------------------

ll llmax(ll a, ll b) {return (a>b?a:b);}
int main(int argc, char const *argv[]) {
  ll P, a, b, c;
  std::cin >> V >> E >> P;
  for(int i=0;i<E;i++){
    std::cin >> a >> b >> c;
    es[i]=edge{a, b, P-c};
  }
  ll check = bellman(1);
  if(check == 0) std::cout << llmax(0, -d[V]) << '\n';
  else std::cout << -1 << '\n';
  return 0;
}


Measured memory_bytes: 2432
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)105;

using namespace std;

int n, a[N], b[N], dp[N][N];

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n;
	forn(i, n)
		cin >> a[i];
	//~compress
	forn(i, n)
		b[i] = a[i];
	sort(b + 1, b + n + 1);
	int m = unique(b + 1, b + n + 1) - b - 1;
	forn(i, n)
		a[i] = lower_bound(b + 1, b + m + 1, a[i]) - b;
	m++;
	//~solve	
	fill(dp[1] + 1, dp[1] + m + 1, 1);
	dp[1][a[1]] = 0;
	for (int i = 2; i <= n; i++)	
	{
		forn(j, m)
		{
			dp[i][j] = i;
			forn(k, m)
			{
				if (j == k)
					continue;
				dp[i][j] = min(dp[i][j], dp[i - 1][k] + bool(j != a[i]));
			}
		}
	}
	//~result
	int ans = n;
	forn(i, m)
		ans = min(ans, dp[n][i]);
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n;
ll a[100005],b[100005];
ll d1[100005],dn[100005];
ll f,s;
int main(void){
    cin>>n;
    vector<ll> G[100005];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    queue<ll> q;
    fill(d1,d1+(n+1),1000000000000000);
    fill(dn,dn+(n+1),1000000000000000);
    q.push(1);
    d1[1]=0;
    while(!q.empty()){
        ll v=q.front();
        q.pop();
        for(int i=0;i<G[v].size();i++){
            ll nv=G[v][i];
            if(d1[nv]>d1[v]+1){
                d1[nv]=d1[v]+1;
                q.push(nv);
            }
        }
    }
    queue<ll> Q;
    Q.push(n);
    dn[n]=0;
    while(!Q.empty()){
        ll V=Q.front();
        Q.pop();
        for(int i=0;i<G[V].size();i++){
            ll nV=G[V][i];
            if(dn[nV]>dn[V]+1){
                dn[nV]=dn[V]+1;
                Q.push(nV);
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(d1[i]<=dn[i]){
            f++;
        }else{
            s++;
        }
    }
    //cout<<f<<" "<<s<<endl;
    if(f<=s){
        cout<<"Snuke"<<endl;
    }else{
        cout<<"Fennec"<<endl;
    }
}


Measured memory_bytes: 12828
#include <stdio.h>
#include <math.h>
int main(){
	int a,b,d,r,i,cnt=0;
	double f;
	scanf("%d %d",&a,&b);
	d = a/b;
	r = a%b;
	f = (double)a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 3e5 + 10;
const int M = (int) 1e6 + 10;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF + 2;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;

const int nx[4] = {0, 0, -1, 1};
const int ny[4] = {1, -1, 0, 0};

int n;
ll a[N];
map<ll, int> cnt;

int main() {
  #define fn "saddle"
  #ifdef witch
      freopen("input.txt", "r", stdin);
  //    freopen("output.txt", "w", stdout);
  #else
      //freopen(fn".in", "r", stdin);
      //freopen(fn".out", "w", stdout);
  #endif
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
    cnt[a[i - 1]]++;
    ans += cnt[a[i]];
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string X;
  cin>>X;
  if(X=="A")X="A";
  else if(X=="B")X="BB";
  else if(X=="C")X="CCC";
  else if(X=="D")X="DDDD";
  else if(X=="E")X="EEEEE";
  else X="FFFFFF";
  string Y;
  cin>>Y;
  if(Y=="A")Y="A";
  else if(Y=="B")Y="BB";
  else if(Y=="C")Y="CCC";
  else if(Y=="D")Y="DDDD";
  else if(Y=="E")Y="EEEEE";
  else Y="FFFFFF";
  
  if(X.size()>Y.size())cout<<">";
  else if(X.size()<Y.size())cout<<"<";
  else cout<<"=";
  cout<<endl;
}
  


Measured memory_bytes: 256
H,W=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(10)]
for i in range(10):
  for j in range(10):
    for k in range(10):
      s[j][k]=min(s[j][k],s[j][i]+s[i][k])
ans=0
change=[s[i][1] for i in range(10)]
for _ in range(H):
  t=list(map(int,input().split()))
  ans+=sum(change[i] for i in t if i !=-1)
print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<string> b(N);
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }
    int M;
    cin >> M;
    vector<string> r(M);
    for (int i = 0; i < M; i++) {
        cin >> r[i];
    }
    int ans = 0;
    for (string s : b) {
        int score = 0;
        for (string sb : b) {
            if (s == sb) score++;
        }
        for (string sr : r) {
            if (s == sr) score--;
        }
        ans = max(score, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
use proconio::{fastout, input};
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    // implementation
    let s_hashset: HashSet<String> = s.into_iter().collect();
    println!("{}", s_hashset.len())
}


Measured memory_bytes: 21428
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n, tmp, max, min, nread;
    long sum;
    char buf[80000];

    fgets(buf, 256, stdin);
    sscanf(buf, "%d", &n);

    min = 1000000;
    max = -1000000;
    sum = 0;

    memset(buf, 0, 80000);
    fgets(buf, 80000, stdin);

    sscanf(strtok(buf, " "), "%d", &tmp);
    if (tmp < min) min = tmp;
    if (tmp > max) max = tmp;
    sum += tmp;
    for (; n > 1; --n)
    {
        sscanf(strtok(NULL, " "), "%d", &tmp);
        if (tmp < min) min = tmp;
        if (tmp > max) max = tmp;
        sum += tmp;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<cmath>
#include<vector>
#include<string>

using namespace std;

int main(){
  int a,b,x,index=0;
  string op;
  vector<int> vec;

  while( cin>>op){
    if ( op == "+" ){
      a=vec.back();
      vec.pop_back();
      b=vec.back();
      vec.pop_back();
      vec.push_back(a+b);
    } else if ( op == "-" ){
      a=vec.back();
      vec.pop_back();
      b=vec.back();
      vec.pop_back();
      vec.push_back(b-a);

    } else if ( op == "*" ){
      a=vec.back();
      vec.pop_back();
      b=vec.back();
      vec.pop_back();
      vec.push_back(a*b);

    } else {
      x = stoi(op);
      vec.push_back(x);
      index++;
    }
  }
  cout<<vec.at(0)<<endl;
  return 0;
}



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

int main() {
  int A, B;
  cin >> A >> B;
  int a, b, c;
  a = A + B;
  b = A - B;
  c = A * B;
  if (B >= 0) {
    cout << ((a > c) ? a : c) << "\n";
  } else {
    cout << ((b > c) ? b : c) << "\n";
  }
  return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct RootedTree {
    RootedTree(int n, int root = 0) :
            mRoot(root) {
        mVertexTbl.resize(n);
    }

    void addEdge(int a, int b, long long int cost = 1) {
        mVertexTbl[a].child.push_back(pair<int, long long int>(b, cost));
        mVertexTbl[b].child.push_back(pair<int, long long int>(a, cost));
    }

    void build() {
        queue<tuple<int, int, long long int>> q;
        q.push(make_tuple(mRoot, -1, 0));
        while (!q.empty()) {
            auto t = q.front();
            q.pop();
            int index = get<0>(t);
            int parent = get<1>(t);
            long long int depth = get<2>(t);
            mVertexTbl[index].parent = parent;
            mVertexTbl[index].depth = depth;
            for (auto it = mVertexTbl[index].child.begin(); it != mVertexTbl[index].child.end();) {
                int nxt = (*it).first;
                if (nxt == parent) {
                    mVertexTbl[index].child.erase(it);
                    continue;
                }
                q.push(make_tuple(nxt, index, depth + (*it).second));
                ++it;
            }
        }
    }

    struct Vertex {
        vector<pair<int, long long int>> child;
        long long int depth = 0;
        int parent = -1;
        ll count = 0;
    };

    int mRoot;
    vector<Vertex> mVertexTbl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    RootedTree tree(N);
    REP(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        tree.addEdge(a, b);
    }

    REP(i, Q) {
        ll p, x;
        cin >> p >> x;
        p--;
        tree.mVertexTbl[p].count += x;
    }
    tree.build();

    queue<ll> q;
    q.push(0);
    while (!q.empty()) {
        ll t = q.front();
        q.pop();

        ll count = tree.mVertexTbl[t].count;
        REP(i, tree.mVertexTbl[t].child.size()) {
            ll n = tree.mVertexTbl[t].child[i].first;
            tree.mVertexTbl[n].count += count;
            q.push(n);
        }
    }

    REP(i, N) {
        cout << tree.mVertexTbl[i].count << " ";
    }
    cout << endl;
    return 0;
}

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

int main() {
  int n,m;
  cin>>n;
  std::vector<int> d(n);
  for(int i=0;i<n;i++)cin>>d[i];
  cin>>m;
  int good=0;
  std::vector<int> t(m);
  for(int i=0;i<m;i++)cin>>t[i];
  sort(d.begin(),d.end());
  sort(t.begin(),t.end());
  int j=0;
for(int i=0;i<n;i++){
  if(d[i]==t[j])j++;
  if(j==m){good++;break;}
}
if(good)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
void me()
{
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
typedef long long ll;
#define bay_bay return 0;
#define forn for(int i=0;i<n;++i)
#define forsz for(int i=0;i<s.size();++i)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) v.size()
void stop() {
#ifndef ONLINE_JUDGE
system("pause");
#endif
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll arr[1000009];
int main()
{
me();
map<int,int>mp;
int n=3;
while(n--)
{
    int a;
    cin>>a;
    mp[a]++;

}
if(mp[5]==2&&mp[7]==1)
    cout<<"YES"<<endl;
else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
x, y, z, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort(reverse=True)

e = [a_i + b_j for b_j in b for a_i in a]
e.sort(reverse=True)

ans = [e_i + c_j for c_j in c[:k] for e_i in e[:k]]
ans.sort(reverse=True)

for i in ans[:k]:
    print(i)

Measured memory_bytes: 209628
#include<stdio.h>
int main(void)
{
	int t,n,s,f,i,sum=0;
	while (1){
		sum=0;
	scanf ("%d",&t);
	if (t==0)
	break ;
	scanf ("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%d%d",&s,&f);
		sum+=f-s;
	}
	if (t<=sum)
	printf ("OK\n");
	else 
	printf ("%d\n",t-sum);
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	vector<int> A;
	A.push_back(0);
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	A.push_back(0);
	ll sum = 0;
	for(int i = 1; i < N + 2; i++) sum += abs(A[i] - A[i - 1]);
	for(int i = 1; i < N + 1; i++) {
		cout << sum - abs(A[i - 1] - A[i]) + abs(A[i - 1] - A[i + 1]) - abs(A[i] - A[i + 1]) << "\n";
	}
	return 0;
}


Measured memory_bytes: 1784
#include<iostream>
#include<array>
using namespace std;
int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	std::sort(a, a + 3);
	int count = 0;
	count += a[2] - a[1];
	int i = count;
	if ((a[2] - a[0] - count) % 2 == 0) {
		count =count+ (a[2] - a[0] - i) / 2;
	}
	else
		count += (a[2] - a[0] - i) / 2 + 2;
	cout << count << endl;
	return 0;
}

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

int a[5000],b[5000];
int main(){
    int MAX=0;
    int c,d;
    cin>>c>>d;
    for(int e=0;e<c;e++)scanf("%d",&a[e]);
    for(int f=0;f<d;f++)scanf("%d",&b[f]);
    for(int g=0;g<d;g++){
	int sum=0;
	for(int h=0;h<c&&g+sum<d;h++){
	    if(a[h]==b[g+sum])sum++;
	    }
	    MAX=max(MAX,sum);
	}
	cout<<MAX<<endl;
    }

Measured memory_bytes: 3252
package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	// scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	a, b := scanInt(), scanInt()
	fmt.Println(lcm(a, b))
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}


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

int gcd(int x, int y) {
  if (x == 1 || y == 1) return 1;
  if (x % y == 0) return abs(y);
  else return gcd(y, x % y);
}

int main(){
  int n, x; cin >> n >> x;
  vector<int> v(n+1); v[n] = x;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int ans = v[1] - v[0];
  for (int i = 1; i < n; i++) {
    ans = gcd(ans, v[i+1] - v[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def main():
    s = input().strip()
    k = int(input())

    d = [[s[0], 1]]
    for i in range(1, len(s)):
        if s[i] == d[-1][0]:
            d[-1][1] += 1
        else:
            d.append([s[i], 1])
    
    if len(d) == 1:
        print((len(s) * k) // 2)
    else:
        ans = 0
        for c, count in d:
            ans += count // 2
        ans *= k
        if d[0][0] == d[-1][0]:
            a = d[0][1]
            b = d[-1][1]
            ans -= ((a//2) + (b//2) - ((a+b)//2)) * (k-1)
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3192
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 9180
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=500010;
int n, x, num;
int cnt[maxn], tree[maxn], pos[26][maxn];
ll ans;
char s[maxn];
bool v[maxn];
inline void add(int x, int delta){for(;x<=n;x+=x&-x) tree[x]+=delta;}
inline int query(int x){int sum=0; for(;x;x-=x&-x) sum+=tree[x]; return sum;}
int main()
{
    scanf("%s", s+1); n=strlen(s+1);
    for(int i=1;i<=n;i++) cnt[x=s[i]-'a']++, pos[x][++pos[x][0]]=i, tree[i]=i&-i;
    for(int i=0;i<26;i++) if(cnt[i]&1) num++;
    if(num>1) return puts("-1"), 0;
    for(int i=1;i<=n;i++)
    if(!v[i])
    {
        int x=s[i]-'a', nxt=pos[x][pos[x][0]--];
        if(i==nxt) ans+=(query(n)-query(i))>>1;
        else ans+=query(n)-query(nxt);
        add(i, -1); add(nxt, -1); v[i]=v[nxt]=1;
    }
    printf("%lld\n", ans);
}

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

#define ll long long
#define nmax 8

bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
    bool all_visited = true;

    for(int i=0;i<N;i++){
        if(visited[i]==false)all_visited = false;
    }

    if(all_visited)return 1;    /*全訪問で+1*/

    int ret=0;

    for(int i=0;i<N;i++){
        if(graph[v][i]==false)continue;
        if(visited[i])continue; /*探索済みならばcontinue*/

        visited[i] = true;  /*未探索ならばvisited(true)へ変更*/
        ret += dfs(i,N,visited);
        visited[i]=false;
    }

    return ret;
}

int main(){

    int i,j,k;
    int N,M;
    cin >> N >> M;

    for(i=0;i<M;i++){
        int A,B;
        cin >> A >> B;
        graph[A-1][B-1] = graph[B-1][A-1] = true;
    }

    bool visited[nmax];

    for(i=0;i<N;i++){
        visited[i] = false;
    }
    
    visited[0] = true;

    cout << dfs(0,N,visited) << endl;

    return 0;

}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<ll>>stu(n, vector<ll>(2));
	vector<vector<ll>>che(m, vector<ll>(2));
	for (int i = 0; i < n; i++)cin >> stu.at(i).at(0) >> stu.at(i).at(1);
	for (int i = 0; i < m; i++)cin >> che.at(i).at(0) >> che.at(i).at(1);
	for (int i = 0; i < n; i++) {
		ll dis = 1000000000000000000;
		ll pos = -1;
		for (int j = 0; j < m; j++) {
			ll md = abs(stu.at(i).at(0) - che.at(j).at(0)) + abs(stu.at(i).at(1) - che.at(j).at(1));
			if (md < dis) {
				dis = md;
				pos = j;
			}
		}
		cout << pos+1 << endl;
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i = 0; i < n; i++) {
    vec.at(i) = i + 1;
  }
  int o = 0;
  for(int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for(int j = 0; j < d; j++) {
      int a;
      cin >> a;
      for(int b = 0; b < n; b++) {
        if(vec.at(b) == a) {
          vec.erase(vec.begin() + b);
          n--;
        }
      }
    }
  }
  cout << n << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  sort(all(a));

  cout << a[sz(a) - 1] - a[0] << endl;

  return 0;
}

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

bool solve() {
  int A, B, C;
  cin >> A >> B >> C;
  rep(i, 1, 1000) {
    if(A * i % B == C) return true;
  }
  return false;
}

int main() {
  cout << (solve() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	h, n := readInt(), readInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], b[i] = readInt(), readInt()
	}

	const max = 1000000000
	dp := make([]int, h+1)
	for i := range dp[:h] {
		dp[i] = max
	}

	for i := h; i >= 1; i-- {
		for j := 0; j < n; j++ {
			nh := 0
			if v := i - a[j]; v > 0 {
				nh = v
			}
			dp[nh] = min(dp[nh], dp[i]+b[j])
		}
	}
	fmt.Println(dp[0])
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>



int main()
{
	int x = 0, y = 0;

	std::cin >> x >> y;

	std::vector<std::vector<int>> g = {
		{ 1, 3, 5, 7, 8, 10, 12 } ,
		{ 4, 6, 9, 11},
		{ 2 }
	};

	bool flag = false;

	for (auto a : g)
	{
		if (std::find(a.cbegin(), a.cend(), x) != a.cend() &&
			std::find(a.cbegin(), a.cend(), y) != a.cend())
		{
			flag = true;
		}

	}

	if (flag)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;




	return 0;
}


Measured memory_bytes: 256
##入力は以下の形式で標準入力から与えられる.
##N
n = gets.chomp.to_i
##p n

##1個 4ドルのケーキと 1個 7ドルのドーナツが売られている.
##このとき, 合計金額が Nドルとなる買い方はあるか, 判定せよ.
##ただし, 同じ商品を二個以上買っても良く, 買わない商品があっても良いものとする.

way_n = 0
ptn_c = n/4 + 1
ptn_d = n/7 + 1

ptn_c.times do |num_c|
  ptn_d.times do |num_d|
    way_n += 1 if n == (4*num_c + 7*num_d)
  end
end

##合計が Nドルとなる買い方がある場合 
if way_n > 0
  puts 'Yes'
##そうでない場合
else
  puts 'No'
end
##と出力せよ.

Measured memory_bytes: 1788