akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B, C);
  print(A+B < C ? "No" : "Yes");
}


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

using namespace std;

int ans = 0, N, M, K, a[16], dp[(1 << 16) + 5][16];
const int mod = 1e9 + 7;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

int inv[(1 << 16) + 5], fac[(1 << 16) + 5];
void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = power (fac[lim], mod - 2);for (int i=lim - 1; i>=0; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){if (K > N || N < 0 || K < 0) return 0; int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M), Prec (1 << N), K = 1 << N;
for (int i=0; i<M; i++)
    scanf ("%d", &a[i]);
dp[0][0] = 1;
for (int i=0; i<(1 << N); i++)
{
    int curr = 0;
    for (int j=max (M - 1, 0); j>=0; j--)
        if ((i != 0 || j == 0) && dp[i][j] > 0)
        {
            adto (curr, dp[i][j]);
            for (int k=0; k<N; k++)
                if ((i & (1 << k)) == 0)
                {
                    int lim = j - 1;
                    if (i == 0) lim = M - 1;
                    for (int p=0; p<=lim; p++)
                        if (K - a[p] - i >= (1 << k) - 1)
                            adto (dp[i | (1 << k)][p], mul (dp[i][j], comb (K - a[p] - i, (1 << k) - 1)));
                }
        }
    int leftValues = K - 1 - i;
    for (int j=0; j<N; j++)
        if ((i & (1 << j)) == 0)
        {
            curr = mul (curr, comb (leftValues, 1 << j));
            leftValues -= (1 << j);
        }
    int sg = 0;
    for (int j=0; j<N; j++)
        if (i & (1 << j))
            sg ^= 1;
/*    if (sg == 0) printf ("%d +%d\n", i, curr);
    else printf ("%d -%d\n", i, curr);*/
    if (sg == 0) adto (ans, curr);
    else ans = subtract (ans, curr);
}
for (int i=0; i<N; i++)
    ans = mul (ans, fac[1 << i]);
ans = mul (ans, K);
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int i,n,m;
    while(1){
        cin>>n>>m;
        if(n==0)break;
        
        vector<int> s(n),u(m);
for(i=0;i<n;i++)
cin>>s[i];
for(i=0;i<m;i++)
cin>>u[i];
int sum1=0,sum2=0;
for(i=0;i<n;i++)
sum1+=s[i];
for(i=0;i<m;i++)
sum2+=u[i];
int d=sum1-sum2;
int ans[3]={0,0,1000};
int mem;
int x;
for(i=0;i<n;i++){
    for(int j=0;j<m;j++){
        mem=s[i]-u[j];
        mem=mem*2;
if(d==mem){
x=s[i]+u[j];
if(ans[2]>x){
ans[0]=s[i];
ans[1]=u[j];
ans[2]=x;
}
break;
}
    }
}
if(ans[2]==1000)
cout<<-1<<endl;
else
cout<<ans[0]<<" "<<ans[1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3092
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005

void solve()
{
	ll k;
	cin>>k;
	ll a,b;
	cin>>a>>b;
	ll num=(a+k-1)/k;
	num*=k;
	cout<<(num<=b?"OK":"NG")<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

struct P {
   int y, x;
};

const int INF = 1e8;
int H, W;
char B[60][60];
int dist[60][60];

int main() {
   cin >> H >> W;
   int black = 0;
   rep (i, H) {
      rep (j, W) {
         cin >> B[i][j];
         if (B[i][j] == '#') black++;
      }
   }

   rep (i, H) {
      rep (j, W) {
         dist[i][j] = INF;
      }
   }
   queue<P> que;
   que.push(P{0, 0});
   dist[0][0] = 0;
   while (que.size()) {
      P p = que.front(); que.pop();
      int y = p.y, x = p.x;
      rep (i, 4) {
         int ny = y + dy[i], nx = x + dx[i];
         if (ny < 0 || ny >= H || nx < 0 || nx >= W || B[ny][nx] == '#' || dist[ny][nx] != INF) continue;
         dist[ny][nx] = dist[y][x] + 1;
         que.push(P{ny, nx});
      }
   }

   int n = dist[H-1][W-1];
   if (n == INF) {
      cout << -1 << endl;
   } else {
      cout << H*W - black - n - 1 << endl;
   }

   return 0;
}

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

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


    vector<int> num(n);
    for (int i = 0; i < n; i++) {
        num[i] = i;
    }

    vector<pair<double,double>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }


    double sum = 0;
    do {
        for(int i = 1; i < n; i++){
            double dx = (a[num[i]].first - a[num[i - 1]].first) * (a[num[i]].first - a[num[i - 1]].first);
            double dy = (a[num[i]].second - a[num[i - 1]].second) * (a[num[i]].second - a[num[i - 1]].second);

            double dist = sqrt(dx + dy);
            sum += dist;
        }
    } while(next_permutation(num.begin(),num.end()));

    double f = 1;
    for (double i = 1; i <= n; i++) {
        f *= i;
    }
    cout << fixed << setprecision(10) << sum / f << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.size();
    ll res = n * (n - 1) / 2;
    for (ll i = 0; i < 26; i++)
    {
        ll cnt = 0;
        ll c = (char)('a' + i);
        for (ll j = 0; j < n; j++)
        {
            if (s[j] == c)
            {
                cnt++;
            }
        }
        res -= (cnt * (cnt - 1) / 2);
    }
    cout << res + 1 << endl;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#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;

int main(int argc, char const *argv[]) {
  string S;
  std::cin >> S;
  std::vector<int> las(S.size());
  std::vector<int> alpha(26, 0);
  int c=0, cycle=0;
  for(int i=S.size()-1;i>=0;i--){
    if(alpha[S[i]-'a']==0) c++;
    alpha[S[i]-'a']++;
    las[i] = cycle;
    if(c==26) {
      cycle++, c = 0;
      for(int j=0;j<26;j++) alpha[j] = 0;
    }
  }
  string ans = "";
  int now = 0;
  bool flag = true;
  while(true){
    if(las[now]==0){
      map<int, int> t;
      int k = 0;
      for(int i=now;i<S.size();i++) if(t.find(S[i]-'a')==t.end()) k++,t.emplace(S[i]-'a', i);
      if(k==26) ans += 'a', now = t.at(0)+1;
      flag = false;
    }
    if(!flag) break;
    for(int j=0;j<26;j++) alpha[j] = 0;
    c=0;
    multiset<std::vector<int>> mp;
    while(true){
      if(alpha[S[now]-'a']==0) {
        c++;
        mp.insert(std::vector<int> {las[now], S[now]-'a', now});
        alpha[S[now]-'a']=1;
      }
      if(c==26) break;
      now++;
    }
    std::vector<int> tmp = *mp.begin();
    ans += (tmp[1]+'a');
    now = (tmp[2]+1);
    //std::cout << now << '\n';
  }
  //for(int i=0;i<S.size();i++) std::cout <<S[i] << " " << las[i] << " " << i<< endl;
  // last_one
  //-------------------------------------------------------------------
  //std::cout << now << '\n';
  set<int> ls;
  for(int i=0;i<26;i++) ls.insert(i);
  for(int i=now;i<S.size();i++) if(ls.find(S[i]-'a')!=ls.end()) ls.erase(S[i]-'a');
  ans += (*ls.begin() + 'a');
  //-------------------------------------------------------------------
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1404
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=int(0)
ans=int(0)

for i in range(n):
    if A[i]+A[i+1]>B[i]:
        ans+=B[i]
        if A[i]>B[i]:
            A[i]-=B[i]
            B[i]=0
        else:
            B[i]-=A[i]
            A[i]=0
            A[i+1]-=B[i]

    else:
        ans+=A[i]+A[i+1]
        A[i]=0
        A[i+1]=0

print(ans)

Measured memory_bytes: 18752
n, m, l = map(int,input().split())
a = [list(map(int, input().split()))for i in range(n)]
b = [list(map(int, input().split()))for j in range(m)]
num = [[0 for i in range(l)]for j in range(n)]
for k in range(n):
    for i in range(l):
        for j in range(m):
            num[k][i] += a[k][j] * b[j][i]
for i in range(n):
    print(" ".join(map(str, num[i])))



Measured memory_bytes: 6888
#include<stdio.h>

int main(void){
  long long n;
  scanf("%lld",&n);

  long long ans;
  ans = (n/11) * 2;
  if(n%11 != 0){
    ans ++;
    if(n%11 > 6){
      ans ++;
    }
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2
 
using namespace std;

char s[ 100010 ];

int main() {
	int n, ans = 1;
	scanf( "%d", &n );
	scanf( "%s", s );
	for( int i = 1; i < n; ++i )
		if( s[ i ] != s[ i - 1 ] )
			++ans;
	printf( "%d", ans );
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ALDS1_1_A
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            for(int i = 0; i < n; i++)
            {
                var v = a[i];
                var j = i - 1;

                while(j >= 0 && a[j] > v)
                {
                    a[j + 1] = a[j];
                    j--;
                }

                a[j + 1] = v;

                string aa = "";

                for(int k = 0; k < n; k++)
                {
                    aa += a[k];

                    if(k != n - 1)
                    {
                        aa += " ";
                    }
                }

                Console.WriteLine(aa);
            }
        }
    }
}



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

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

using namespace std;

typedef long long int ll;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t, d, l;
    while (cin >> t >> d >> l, t + d + l) {
        int ans = 0;
        int prev = 0;
        bool use = false;
        REP(i, 0, t) {
            int x;
            cin >> x;
            if (x >= l) {
                if (!use) {
                    prev = i;
                }
                use = true;
                ans += min(i - prev, d);
                prev = i;
            }
        }
        dump(ans);
        if (use) {
            ans += min(t - prev - 1, d);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3140
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

int main()
{
  int n,i,j;
  string s,t;
  bool f;
  while(getline(cin,s)){
    f=true;
    for(i=0;f && i<26;i++){
      t=s;
      for(j=0;j<t.size();j++){
	if(!islower(t[j]))continue;
	t[j]-='a';
	t[j]=(t[j]+i)%26;
	t[j]+='a';
      }
      if(t.find("this ",0)==0)f=false;
      if(t.find("that ",0)==0)f=false;
      if(t.find("the ",0)==0)f=false;
      if(t.find(" this",t.size()-5)==t.size()-5)f=false;
      if(t.find(" that",t.size()-5)==t.size()-5)f=false;
      if(t.find(" the",t.size()-4)==t.size()-4)f=false;
      if(t.find(" this ")!=string::npos)f=false;
      if(t.find(" that ")!=string::npos)f=false;
      if(t.find(" the ")!=string::npos)f=false;
    }
    cout<<t<<endl;
  }
}

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

int main() {
  int n, m; cin>>n>>m;
  if (n % 2 == 0) {
    int w = n-1;
    int pos = 1;
    for (int i = 0; i < (m+1)/2; i++) {
      cout << pos << ' ' << pos + w << endl;
      ++pos;
      w -= 2;
    }
    w = 2;
    pos = n/2;
    for (int i = (m+1)/2; i < m; i++) {
      cout << pos << ' ' << pos + w << endl;
      --pos;
      w += 2;
    }
  } else {
    int w = n-1;
    int pos = 1;
    for (int i = 0; i < m; i++) {
      cout << pos << ' ' << pos + w << endl;
      ++pos;
      w -= 2;
    }
  }

  return 0;
}

Measured memory_bytes: 3612
/*
TEMPLATE
by.YXH_XianYu
   2018.7.14
*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LLI long long
#define DBL double
#define CHR char
#define BOL bool
#define REG register
#define rep(i, j, k) for(int i = j, lim = k; i <= lim; i++)
#define req(i, j, k) for(int i = j, lim = k; i >= lim; i--)
#define MXN 105

int n,
	a[MXN],
	ans;

int main() {
	//freopen("TEMPLATE.in", "r", stdin);
	//freopen("TEMPLATE.out", "w", stdout);
	
	scanf("%d", &n);
	rep(i, 1, n)
		scanf("%d", &a[i]);
	rep(i, 2, n)
		if(a[i-1] == a[i])
			a[i] = -1,
			ans++;
	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c)
		cout << "Yes" << "\n";
	else if (a == c && a != b)
		cout << "Yes" << "\n";
	else if (b == c && b != a)
		cout << "Yes" << "\n";
	else if (a == b && b == c)
		cout << "No" << "\n";
	else
		cout << "No" << "\n";
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100001],dp[100001];
int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++)
    {
        dp[i] = 1e9;
        cin >> a[i]; if(i==1){ dp[i] = 0; continue; }
        for(int j=1; j<=k; j++) if(i - j > 0)dp[i] = min(dp[i],dp[i-j] + abs(a[i] - a[i-j]));
    }
    cout << dp[n];
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
struct UnionFind {
	vector<int> par;
	UnionFind(int N) : par(N) { rep(i, 0, N)par[i] = i; }
	int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
	void unite(int x, int y) { if (!same(x, y)) par[root(x)] = root(y); }
	bool same(int x, int y) { return root(x) == root(y); }
	map<int, int> cnt() { map<int, int> cnt; rep2(v, par)cnt[root(v)]++; return cnt; }
};
int main()
{
	int n, m, k, a, b;
	cin >> n >> m >> k;
	UnionFind tree(n);
	vector<int> bad(n);
	rep(i, 0, m) {
		cin >> a >> b;
		tree.unite(a - 1, b - 1);
		bad[a - 1]++, bad[b - 1]++;
	}
	auto cnt = tree.cnt();
	rep(i, 0, k) {
		cin >> a >> b;
		if (tree.same(a - 1, b - 1))bad[a - 1]++, bad[b - 1]++;
	}
	rep(i, 0, n)printf("%d ", cnt[tree.root(i)] - bad[i] - 1);
	return 0;
}

Measured memory_bytes: 8548
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

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

int ma[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};

string maxs(string a, string b){
  if(a == "a")return b;
  if(b == "a")return a;
  if(a.size() != b.size()){
    if(a.size() > b.size())return a;
    else return b;
  }
  for(int i = 0; i < sz(a); i++){
    if(a[i] != b[i]){
      if(a[i] < b[i])return b;
      else return a;
    }
  }
  return a;
}

int main(int argc, char const* argv[])
{
  int n, m;
  cin >> n >> m;
  vector<string> dp;
  for(int i = 0; i <= 10001; i++)dp.pb("a");
  vector<int> a(m);
  rep(i, m)cin >> a[i];
  rep(i, m){
    dp[ma[a[i]-1]] = maxs(dp[ma[a[i]-1]], to_string(a[i]));
  }
  dp[0] = "";
  for(int i = 1; i <= n; i++){
    for(int j = 0; j < m; j++){
      if(i - ma[a[j]-1] >= 0 && dp[i-ma[a[j]-1]] != "a"){
        dp[i] = maxs(dp[i], dp[i-ma[a[j]-1]] + to_string(a[j]));
      }
    }
  }
  cout << dp[n] << endl;
	return 0;
}


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

using namespace std;

string s;
long long k, ans;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> s >> k;
    vector<int> v;
    for (int i = 0; i < s.size(); ) {
        int pos = i;
        while (i < s.size() && s[i] == s[pos]) {
            ++i;
        }
        v.push_back(i - pos);
    }
    if (v.size() == 1) {
        ans = k * s.length();
        ans /= 2;
    } else if (s[0] == s.back()) {
        ans = (v[0] + v.back()) / 2;
        for (int i = 1; i + 1 < v.size(); ++i) {
            ans += v[i] / 2;
        }
        ans *= (k - 1);
        for (int x : v) {
            ans += x / 2;
        }
    } else {
        for (int x : v) {
            ans += x / 2;
        }
        ans *= k;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());
#define vnn(x,y,name) vector<vector<int>> name(x, vector<int>(y));

string yes="Yes",no="No";

int main() {
    int n;
    cin>>n;
    vin a(n);
    vin cnt(n);
    rep(i,n){
        cin>>a[i];
        cnt[a[i]-1]++;
    }
    ll sum=0;

    rep(i,n){
        sum+=(ll)cnt[i]*((ll)cnt[i]-1)/2;
    }
    rep(i,n){
        cout<<sum-(ll)cnt[a[i]-1]+1<<endl;
    }
    
}


Measured memory_bytes: 4844
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	var t Tree
	t.h = getNextInt(scanner)

	t.nodes = make([]Node, t.h+1)
	for i := 1; i <= t.h; i++ {
		t.nodes[i].key = getNextInt(scanner)
	}
	t.BuildMaxHeap()
	for i := 1; i <= t.h; i++ {
		fmt.Fprintf(writer, " %d", t.nodes[i].key)
	}
	fmt.Fprintln(writer, "")
	writer.Flush()
}

// Node ...
type Node struct {
	key int
}

// Tree ...
type Tree struct {
	nodes []Node
	h     int
}

// MaxHeapify ...
func (t *Tree) MaxHeapify(i int) {
	var largest int
	l := i * 2
	r := i*2 + 1
	if l <= t.h && t.nodes[l].key > t.nodes[i].key {
		largest = l
	} else {
		largest = i
	}
	if r <= t.h && t.nodes[r].key > t.nodes[largest].key {
		largest = r
	}
	if largest != i {
		t.nodes[i], t.nodes[largest] = t.nodes[largest], t.nodes[i]
		t.MaxHeapify(largest)
	}

}

// BuildMaxHeap ...
func (t *Tree) BuildMaxHeap() {
	for i := t.h >> 1; i > 0; i-- {
		t.MaxHeapify(i)
	}
}



Measured memory_bytes: 10100
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  string s;
  cin >> s;
  int N = s.size();
  
  int ans = 101;
  for(char ch = 'a'; ch <= 'z'; ch++){
    int cnt = 0;
    int tmp = 0;
    REP(i, N){
      if(s[i] != ch) cnt++;
      
      if(s[i] == ch || i == N-1 ){
        if(tmp < cnt )tmp = cnt;
        cnt = 0;
      }
    }
    ans = min(ans, tmp);
  }

  cout << ans << endl;
}


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

s_list = []
for i in range(M):
    s_list.append(list(map(int, input().split())))
P_list = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    S = ["OFF" for _ in range(N)]
    for j in range(N):
        if (i >> j) & 1 == 1:
            S[j] = "ON"
    m = 0
    while True:
        cnt = 0
        for s in range(1, len(s_list[m])):
            if S[s_list[m][s]-1] == "ON":
                cnt += 1
        if cnt % 2 != P_list[m]:
            break
        m += 1
        if m == M:
            break
    if m == M:
        ans += 1
print(ans)


Measured memory_bytes: 68692
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  map<string, int> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;
  cout << mp[s] << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n,ma,mb;
int aa[45],bb[45],cc[45];
int dp[45][405][405];
const int INF = 1e9;


int main() {
  cin >> n >> ma >> mb;
  for(int i = 0; i < n; i++) cin >> aa[i] >> bb[i] >> cc[i];
  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= n * 10; j++) {
      for(int k = 0; k <= n * 10; k++) {
	dp[i][j][k] = INF;
      }
    }
  }

  dp[0][0][0] = 0;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= n * 10; j++) {
      for(int k = 0; k <= n * 10; k++) {
	if(dp[i][j][k] == INF) continue;
	dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
	dp[i+1][j+aa[i]][k+bb[i]] = min(dp[i+1][j+aa[i]][k+bb[i]],dp[i][j][k] + cc[i]);
      }
    }
  }
  int ans = INF;
  int tmp = max(ma,mb);
  for(int i = 1; i * tmp <= n * 10; i++) {
  
    ans = min(ans,dp[n][i*ma][i*mb]);
  }

  if(ans == INF) cout <<-1 << endl;
  else cout << ans << endl;
}
  


Measured memory_bytes: 26880
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;

int main() {
	cin >> N;
	vpll A(N);
	for (i = 0; i < N; i++) {
		ll a;
		cin >> a;
		A[i] = make_pair(a, i+1);
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	//i個目まで決めた時にright寄りにj個の最大値
	vll dp(N+1, vl(N+1, 0));
	for (i = 0; i <= N; i++) {
		for (j = 0; j <= N; j++) {
			dp[i][j] = -INF;
		}
	}
	dp[0][0] = 0;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			dp[i + 1][j + 1] = max(dp[i+1][j+1],dp[i][j] + A[i].first * abs(N - j - A[i].second));
			dp[i + 1][j] = max(dp[i+1][j],dp[i][j] + A[i].first * abs(1 + (i-j) - A[i].second));
		}
	}
	
	for (i = 0; i <= N; i++) {
		ans = max(ans, dp[N][i]);
	}
	cout << ans;
}

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

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

int max_n = 1e6 + 1;

void solve() {
    int x;
    cin >> x;
    cout << (x ^ 1);
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


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

int main(){
	int n;
	cin >> n;
	
	for(int i=n;1;++i){
		bool f = true;
		for(int j=2;j*j<=i;++j){
			if(i%j == 0){
				f=false;
				break;
			}
		}
		if(f){
			cout << i <<endl;
			break;
		}
	}
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    char ch;
    cin >> ch;
    if(ch == 'A'){
        cout << 'T' << endl;
    }
    else if(ch == 'T'){
        cout << 'A' << endl;
    }
    else if(ch == 'C'){
        cout << 'G' << endl;
    }
    else if(ch == 'G'){
        cout << 'C' << endl;
    }
}

Measured memory_bytes: 256
w,h,X,Y,C,t,b,d[9][9],q[9][9],a[]={-1,0,1,0};Z(x,y){int i=0,s=1;if(q[y][x])return 0;q[y][x]=1;if(d[y][x])return y==Y&&x==X;for(;i<4;)s+=Z(x+a[i%4],y+a[i++]);return s;}B(x,y,c){int i=0;if(!(c||x-X||y-Y))return 1;memset(q,0,324);if(d[y][x]||Z(x,y)!=c+(x-X||y-Y))return 0;if(b++>95000)return 2;for(d[y][x]=1;i<4;)if(t=B(x+a[i%4],y+a[i++],c-1))return t;return d[y][x]=0;}main(i,j){for(;C=b=j=0,memset(d,-1,324),scanf("%d%d\n",&w,&h),h;puts(C<4||B(X,Y,C)-1?"No":"Yes"))for(;j++<h;)for(i=0;i++<w;)scanf("%d",&t),(d[j][i]=t)||(++C,X=i,Y=j);exit(0);}

Measured memory_bytes: 388
#include <stdio.h>


int main(void) {
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int ans=1;
	if ((a>b?a:b)<c) ans=0;
	if ((a<b?a:b)>c) ans=0;
	if (ans) printf("Yes\n");
	else printf("No\n");	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - 12/22
            var N = Console.ReadLine();

            Console.WriteLine(N.Count(x => x == '2'));
        }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    int a,b,k,r;
    cin >> a >> b >> k;
    swap(a,b);
    while ((r=a%b)) {
    a = b;
    b = r;
    }
    vector<int> ans;
    for(int i=1;i<=b;i++){
        if(b%i==0)
        ans.push_back(i);
    }
    sort(ans.begin(),ans.end(),greater<int>());
    cout << ans[k-1] <<endl;
    return 0;
}

Measured memory_bytes: 384
import math
A,B,H,M=map(int,input().split())
b=2*math.pi*(M/60)
a=2*math.pi*((H/12) + (M/(60*12)))
t=abs(a-b)
if t>math.pi:
  t=2*math.pi-t
print(math.sqrt(A**2+B**2-2*A*B*math.cos(t)))

Measured memory_bytes: 9536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int q = scanner.nextInt();
		boolean[] b = new boolean[300001];
		while (n-- > 0) {
			b[scanner.nextInt()] = true;
		}
		loop: while (q-- > 0) {
			int m = scanner.nextInt();
			for (int res = m - 1; res >= 0; res--) {
				for (int i = res; i <= 300000; i += m) {
					if (b[i]) {
						System.out.println(res);
						continue loop;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 140136
import heapq as hq
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()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans = []
for p in range(1,x+1):
  for q in range(1,y+1):
    for r in range(min(k//(p*q)+1,z)):
      ans.append(-(a[p-1]+b[q-1]+c[r]))
hq.heapify(ans)
for i in range(k):
  s = hq.heappop(ans)
  print(-s)

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

#define ll long long int
#define absdiff(a,b) (a>b)?a-b:b-a
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
const ll ll_MAX = 19223372036859;
const ll MOD = 1000000007;
ll fast_expo(ll x,ll p){if(p==0) return 1;
    else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} 
    else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  
    else return gcd(b%a,a); }

ll n,arr[401],dp[401][401],pre[401];

ll solve(ll i,ll j){
    if(i == j) return 0ll;
    if(i>j) return ll_MAX;
    if(dp[i][j] != -1) return dp[i][j];

    dp[i][j] = ll_MAX;
    for(ll k=i; k<j; ++k){
        dp[i][j] = min(dp[i][j],solve(i,k)+solve(k+1,j)+pre[j]-pre[i-1]);
    }
    return dp[i][j];
}

int main()
{
    ll t_c; t_c = 1;
    // cin >> t_c;
    for(ll t_i=0; t_i<t_c; ++t_i){
        memset(dp,-1,sizeof(dp));
        pre[0] = 0;
        cin >> n;
        for(ll i=1; i<=n; ++i){
            cin >> arr[i];
            pre[i] = pre[i-1]+arr[i];
        }
        
        cout << solve(1,n);
    }   
    return 0;
}

Measured memory_bytes: 1536
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, d = map(int, readline().split())

    ans = max(0, min(b, d) - max(a, c))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61500
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

char b1[3010];
char b2[3010];
int dp[3010][3010];
int trace[3010][3010];
char res[3010];

int main(void) {
  scanf("%s%s", b1, b2);
  int n1 = strlen(b1);
  int n2 = strlen(b2);
  REP(i1, n1) {
    REP(i2, n2) {
      if(b1[i1] == b2[i2]) {
        dp[i1+1][i2+1] = dp[i1][i2] + 1;
        trace[i1+1][i2+1] = 2;
      } else if(dp[i1+1][i2] > dp[i1][i2+1]) {
        dp[i1+1][i2+1] = dp[i1+1][i2];
        trace[i1+1][i2+1] = 0;
      } else {
        dp[i1+1][i2+1] = dp[i1][i2+1];
        trace[i1+1][i2+1] = 1;
      }
    }
  }

  {
    int c1 = n1;
    int c2 = n2;
    for(int i = dp[c1][c2]-1; i >= 0; ) {
      if(trace[c1][c2] == 2) {
        res[i] = b1[c1-1];
        --i;
        --c1;
        --c2;
      } else if(trace[c1][c2] == 0) {
        --c2;
      } else {
        --c1;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 70912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, int[] A)
        {
            for (int i = 0; i < N; ++i) { A[i] -= i + 1; }
            Array.Sort(A);
            int p = (N - 1) / 2;
            int q = (N - 0) / 2;
            int m = (A[p] + A[q]) / 2;
            return A.Sum(a => (long)Math.Abs(a - m));
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] A = ReadInts();
            Console.WriteLine(Solve(N, A));
        }
    }
}


Measured memory_bytes: 34780
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
#define lint long long
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int a,b,h,m;cin>>a>>b>>h>>m;
  double st,lt;
  st=2.0*M_PI/12.0*(m/60.0+h);
  lt=2.0*M_PI/60.0*(m);
  double res=sqrt((a*cos(st)-b*cos(lt))*(a*cos(st)-b*cos(lt))+(a*sin(st)-b*sin(lt))*(a*sin(st)-b*sin(lt)));
  printf("%.12lf\n",res);
  return 0;
}


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

//____________________________________________________________________________________________________________________________________

#define PI  2*acos(0.0)
#define pf  printf
#define sf  scan
#define ff  first
#define ss  second
#define mp  make_pair
#define pb  push_back
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef vector<long long> vll ;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define sc(n)       scanf("%d",&n);
#define scf(f)      scanf("%f",&f);
#define FOR(i,a,n)  for(int i = a; i < n; i++)
#define TEST(test)  for(int cse = 1; cse <= test; cse++)
#define all(x) (x).begin(), (x).end()
#define fap(x) cout << __LINE__ << " says: " << #x << " = " << x << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mst(arr, n) memset(arr, n, sizeof arr)
const ll INF = 2000000000000000000LL;
const int inf = 0x3f3f3f3f;
const long double EPS = 1e-9;
const ll MOD = 1e9 + 7;
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
//____________________________________________________________________________________________________________________________________


int freq[200009];

int main()
{

#ifdef PARTHO
   freopen("C:\\Users\\rnoji\\Desktop\\Partho Code\\IO\\input.txt","r",stdin);
   freopen("C:\\Users\\rnoji\\Desktop\\Partho Code\\IO\\output.txt","w",stdout);
   //int start_time = clock();
#endif


int n, value;

cin >> n;

for(int i = 0 ; i < n - 1; i++)
{
    cin >> value;
    freq[value]++;
}

for(int i = 1; i <= n; i++)
cout << freq[i] << endl;



 return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
using namespace std;
typedef long long ll;

int main(){
        ll N;
        cin >> N;
        vector<ll> A(N);
        for(int i=0; i<N; i++){
                cin >> A[i];
        }
        sort(A.rbegin(), A.rend());
        ll past_point = A[0];
        ll x=0, y=0;
        for(int i=1; i<N; i++){
                ll point = A[i];
                if(past_point == point){
                        if(x == 0) x = point;
                        else if(x!=0){
                                y = point;
                                break;
                        }
                        i++;
                        past_point=A[i];
                }
                else past_point = point;
        }
        cout << x*y;


}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
#define ll long long

int main() {
	ll n, a[200000], hoge, ans;
	cin >> n;
	for (int i = 0; i < 200000; i++)a[i] = 0;
	for (int i = 0; i < n; i++) {
		cin >> hoge;
		a[hoge]++;
	}
	if (a[0] == 1) {
		//奇数
		for (int i = 2; i < n; i = i + 2) {
			if (a[i] != 2) {
				//不適
				cout << 0 << endl;
				return 0;
			}
		}
		ans = 1;
		for (int i = 0; i < ((n - 1) / 2); i++) {
			ans = ans * 2;
			ans = ans % 1000000007;
		}
		ans = ans % 1000000007;
		cout << ans << endl;
		return 0;
	}
	else if (a[0] == 0) {
		//偶数
		for (int i = 1; i < n; i = i + 2) {
			if (a[i] != 2) {
				//不適
				cout << 0 << endl;
				return 0;
			}
		}
		ans = 1;
		for (int i = 0; i < (n / 2); i++) {
			ans = ans * 2;
			ans = ans % 1000000007;
		}
		ans = ans % 1000000007;
		cout << ans << endl;
		return 0;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  vector<int> v[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]--;
    v[a[i]].push_back(i);
  }
  int sum=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<v[i].size();j++){
      if(v[i][j]==a[i])sum++;
    }
  }
  cout<<sum/2<<endl;
}

Measured memory_bytes: 6144
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int  n, m, ans = 0 ; 
int  p[100005] ; 
vi  g[100005],h ; 
map <int,bool> curvis,vis;

void dfs(int u){
    if (vis[u]) return;
    vis[u] = true ; 
    curvis[u] = true ; 
    h.pb(p[u]);
    for (auto &it: g[u])
      if (!vis[it]) dfs(it);
}

signed main()
{
    cin >> n >> m ; 
    for(int i=1;i<=n;i++) cin >> p[i] ; 
    for(int i=1;i<=m;i++) { 
      int  a, b ; 
      cin >> a >> b; 
      g[a]. pb(b) ; 
      g[b]. pb(a) ; 
    } 
    for (int i=1;i<=n;i++){ 
        h.clear(); 
        curvis.clear(); 
        dfs(i); 
        for (auto &it: h){ 
            if (curvis[it]) ans++; 
        } 
    } 
    cout << ans << endl ; 
    return 0;
}


Measured memory_bytes: 28728
#include <cmath>
#include <iostream>

int main()
{
    int N, M, A;
    std::cin >> N >> M;

    int sum = 0;
    for (int i = 0; i < M; ++i)
    {
        std::cin >> A;
        sum += A;
    }

    if (N < sum)
    {
        std::cout << -1 << std::endl;
    }
    else
    {
        std::cout << N - sum << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int n,now,ans;
vector<pair<int,int> > v;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		int x,l;cin>>x>>l;
		v.push_back(make_pair(x+l,x-l));
	}
	sort (v.begin(),v.end());
	now=-2e9;
	for (int i=0;i<n;i++){
		if (v[i].second<now) continue;
		now=v[i].first,now=v[i].first,ans++;
	}
	cout<<ans;
}

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

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int a[n+1];
    int d,m;
    int cnt=0;
    for(int (i)=1;(i)<(n+1);(i)++) a[i]=0;
    rep(i,k){
        scanf("%d",&d);
        // cout <<d;
        rep(j,d){
            // cin >> m;
            scanf("%d",&m);
            // cout << m<<endl;
            a[m]++;
        }
    }
    for(int (i)=1;(i)<(n+1);(i)++){
        // cout << a[i];
        if(a[i]==0){
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


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

// dp[i][j][k] := 寿司の個数が1つの皿の枚数がi枚, 2つがj枚,
// 3つがk枚という状態から
//                寿司がなくなるまでの操作回数の期待値
double dp[302][302][302];

int main() {
  cout << setprecision(20) << fixed;
  int n;
  cin >> n;
  vector<int> cnt(3, 0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cnt[a - 1]++;
  }

  for (int k = 0; k <= n; k++) {
    for (int j = 0; j <= n; j++) {
      for (int i = 0; i <= n; i++) {
        double sum = i + j + k;
        if (sum == 0) {
          continue;
        }
        if (i - 1 >= 0) {
          dp[i][j][k] += dp[i - 1][j][k] * i / sum;
        }
        if (j - 1 >= 0) {
          dp[i][j][k] += dp[i + 1][j - 1][k] * j / sum;
        }
        if (k - 1 >= 0) {
          dp[i][j][k] += dp[i][j + 1][k - 1] * k / sum;
        }
        dp[i][j][k] += n / sum;
      }
    }
  }
  cout << dp[cnt[0]][cnt[1]][cnt[2]] << endl;

  return 0;
}

Measured memory_bytes: 215296
n,m=map(int,input().split())
l=tuple(map(int,input().split()))

ans=float("Inf")
for i in range(n-m+1):
  if l[i+m-1]<0:ret=abs(l[i])
  elif l[i]>0:ret=l[i+m-1]
  else:ret=2*min(abs(l[i+m-1]),abs(l[i]))+max(abs(l[i+m-1]),abs(l[i]))
  ans=min(ret,ans)
print(ans)

Measured memory_bytes: 14988