akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int k;
    string s;
 	cin >> k;
 	cin >> s;

 	if (s.size() <= k)
 	{
 		cout << s;
 	}
 	else
 	{
 		for (int i = 0; i < k; i++)
 		{
 			cout << s[i] ;
 		}
 		cout << "...";
 	}

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <vector>

using std::vector;

int main()
{
    long long n[3];
    long long max = -1000000000, min = 1000000000;
    std::cin>>n[0]>>n[1]>>n[2];
    //std::cout<<n[0]<<" "<<n[1]<<" "<<n[2]<<std::endl;

    for(int i = 0; i < 3; i++)
    {
        if(min>n[i])
        {
            //std::cout<<"flag1"<<std::endl;
            min=n[i];
        }
        if(max<n[i])
        {
            //std::cout<<"flag2"<<std::endl;
            max=n[i];
        }
    }
    std::cout<<min<<" "<<max<<std::endl;
    return 0;
}





Measured memory_bytes: 3112
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int s,u,d;
	cin >> s;
	u = s / 100;
	d = s % 100;
	if ((u==0||u>12)&&0<d&&d<13) {
		cout << "YYMM" << endl;
	}
	else if (0<u&&u<13&&(d==0||d>12)) {
		cout << "MMYY" << endl;
	}
	else if (0<u&&u<13&&0<d&&d<13) {
		cout << "AMBIGUOUS" << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

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

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int maxn = 1e6 + 5;

int n,m,x,a[maxn];

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

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

  int ans = min(a[x], a[n]-a[x]);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
x = int(input())
x -= 1
temp = 1
#ans = ''
# a = chr(97)
# z = chr(97 + 26)
while True:
    mod = x % 26
    div = x // 26

    add = chr(97 + mod)

    if (temp == 1):
        ans = add
    else:
        ans = add + ans

    if (div == 0):
        print(ans)
        exit()

    x /= 26
    x = int(x-1)
    temp += 1
    #print(ans, x)


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> c.at(i);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v.at(i) > c.at(i)) {
      ans += v.at(i) - c.at(i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

C = []
S = []
F = []
for i in range(N - 1):
	cn, sn, fn = list(map(int, input().split()))
	C.append(cn)
	S.append(sn)
	F.append(fn)

for i in range(N):
	x = 0
	for j in range(i, N - 1):
		if x < S[j]:
			x = S[j] + C[j]
		else:
			if (x - S[j]) % F[j] == 0:
				x += C[j]
			else:
				x = S[j] + ((x - S[j]) // F[j] + 1)  * F[j] + C[j]

	print(x)

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int f = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (f == 0 && s[i] == 'C')
            f = 1;
        else if (f == 1 && s[i] == 'F')
            f = 2;
    }
    if (f == 2)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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

using namespace std;

int main(){
    long long a,b,c;    cin>>a>>b>>c;
    long long A = 4*a*b;
    long long B = (c-a-b);
    //cout<<A<<" "<<B<<"\n";
    if(A<B*B && B>0){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	Int T1, T2, A1, A2, B1, B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

	Int Tx = T1 * A1 + T2 * A2;
	Int Ax = T1 * B1 + T2 * B2;

	if (Tx == Ax) {
		cout << "infinity" << endl;
		return 0;
	}

	Int Tx1 = T1 * A1;
	Int Ax1 = T1 * B1;
	if ((Tx1 < Ax1 && Tx < Ax) || (Tx1 > Ax1 && Tx > Ax)) {
		cerr << "fu" << endl;
		cout << 0 << endl;
		return 0;
	}

	if (Tx > Ax) {
		swap(Ax1, Tx1);
		swap(Ax, Tx);
	}
	Int x = (Tx1 - Ax1) / (Ax - Tx);
	Int ans = 2 * x;
	if ((Tx1 - Ax1) % (Ax - Tx) != 0) { ++ans; }
	
	cout << ans << endl;

	return 0;
}


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


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

    ll n;
    cin>>n;
    map<ll,char> mp;
    char ch = 'a';
    For(i,1,27){
    	mp[i] = ch;
    	ch++;
    	// deb2(i,mp[i]);
    }
    string ans="";
    while(n>0){
    	if(n%26 == 0){
    		ans.pb('z');
    		n /= 26;
    		n--;
    		continue;
    	}
    	ans.pb(mp[n%26]);
    	n /= 26;
    	// deb1(n);
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    vector<long long> r(N, 0), g(N, 0), b(N, 0);
    if (S[0] == 'R') ++r[0];
    if (S[0] == 'G') ++g[0];
    if (S[0] == 'B') ++b[0];
    REP(i, N) {
        if (S[i] == 'R') r[i] = r[i - 1] + 1;
        else r[i] = r[i - 1];
        if (S[i] == 'G') g[i] = g[i - 1] + 1;
        else g[i] = g[i - 1];
        if (S[i] == 'B') b[i] = b[i - 1] + 1;
        else b[i] = b[i - 1];
    }
    
    long long ans = 0;
    rep(i, N) for (int j = i + 1; j < N; ++j) {
        if (S[i] == S[j]) continue;
        if (S[i] == 'R' && S[j] == 'G') {
            ans += b[S.size() - 1] - b[j];
            if (j + (j - i) < N) if (S[j + (j - i)] == 'B') --ans;
        }
        if (S[i] == 'R' && S[j] == 'B') {
            ans += g[S.size() - 1] - g[j];
            if (j + (j - i) < N) if (S[j + (j - i)] == 'G') --ans;
        }
        if (S[i] == 'G' && S[j] == 'B') {
            ans += r[S.size() - 1] - r[j];
            if (j + (j - i) < N) if (S[j + (j - i)] == 'R') --ans;
        }
        if (S[i] == 'G' && S[j] == 'R') {
            ans += b[S.size() - 1] - b[j];
            if (j + (j - i) < N) if (S[j + (j - i)] == 'B') --ans;
        }
        if (S[i] == 'B' && S[j] == 'R') {
            ans += g[S.size() - 1] - g[j];
            if (j + (j - i) < N) if (S[j + (j - i)] == 'G') --ans;
        }
        if (S[i] == 'B' && S[j] == 'G') {
            ans += r[S.size() - 1] - r[j];
            if (j + (j - i) < N) if (S[j + (j - i)] == 'R') --ans;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    // 貰うDP
    int N, W; cin >> N >> W;
    vi w(N);
    vi v(N);
    rep(i, N) {
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    rep(i, N) {
        rep(j, W + 1) {
            dp[i + 1][j] = dp[i][j];
            if (j >= w[i]) {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}

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


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

int ans=INF;
int H,W;
vv<char> field;
vv<int> dp;

signed _main(){
  cin >> H >> W;
  field.resize(H+1,v<char>(W+1,'.'));
  dp.resize(H+1,v<int>(W+1,0));
  for(int i=1;i<=H;i++) for(int j=1;j<=W;j++){
    cin >> field[i][j];
  }
  if(field[1][1]=='#') dp[1][1]=1;
  for(int i=1;i<=H;i++) for(int j=1;j<=W;j++){
    if(i==1 && j==1) continue;
    int tmp1=0,tmp2=0;
    if(field[i-1][j]=='.' && field[i][j]=='#') tmp1=1;
    if(field[i][j-1]=='.' && field[i][j]=='#') tmp2=1;
    if(i==1) dp[i][j]=dp[i][j-1]+tmp2;
    else if(j==1) dp[i][j]=dp[i-1][j]+tmp1;
    else dp[i][j]=min(dp[i-1][j]+tmp1,dp[i][j-1]+tmp2);
  }
  cout << dp[H][W] << endl;
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int n, m, v[100100];
vector<int> G[100100];

int main()
{
	scanf ("%d %d", &n, &m);
	for (int i = 0; i < m; i++){
		int x, y; scanf ("%d %d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}

	for (int i = 1; i <= n; i++) v[i] = -1;
	queue<int> q; q.push(1);
	while (!q.empty()){
		int x = q.front(); q.pop();
		for (auto& y : G[x]) if (v[y] == -1){
			q.push(y); v[y] = x;
		}
	}

	for (int i = 2; i <= n; i++) if (v[i] == -1){
		puts("No");
		return 0;
	}
	puts("Yes");
	for (int i = 2; i <= n; i++) printf ("%d\n", v[i]);
	return 0;
}

Measured memory_bytes: 10128
N = int(input())
s = input()
Rnum = 0
Bnum = 0

for n in range(N):
    if s[n]=='R':
        Rnum+=1
    elif s[n]=='B':
        Bnum+=1
        
if Rnum> Bnum:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
  int x[5];
  
  for(int i=0; i<5; i++){
    scanf("%d",&x[i]);
    if(x[i] == 0){
      printf("%d\n",i+1);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
const int MAX_xyz=1000;
const int inf=0x3f3f3f3f;
long long x,y,z,k;
long long a[MAX_xyz+10],b[MAX_xyz+10],c[MAX_xyz+10];
vector<long long> sum;
vector<long long> sum1;
bool comp(long long a,long long b)
{
    return a>b;
}
int main()
{
    cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++)    cin>>a[i];
    for(int i=0;i<y;i++)    cin>>b[i];
    for(int i=0;i<z;i++)    cin>>c[i];
    sort(a,a+x,comp);
    sort(b,b+y,comp);
    sort(c,c+z,comp);
    for(int i=0;i<min(x,k);i++)
    {
        for(int ii=0;ii<min(y,k);ii++)
        {
            sum.push_back(a[i]+b[ii]);
        }
    }
    sort(sum.begin(),sum.end(),comp);
    long long l=sum.size();
    for(int i=0;i<min(l,k);i++)
    {
        for(int ii=0;ii<min(z,k);ii++)
        {
            sum1.push_back(sum[i]+c[ii]);
        }
    }
    sort(sum1.begin(),sum1.end(),comp);
    for(int i=0;i<k;i++)    cout<<sum1[i]<<endl;
    return 0;
}

Measured memory_bytes: 43364
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    double a, s;
    int i;

    for(;sc.hasNext();){
      a = sc.nextDouble();
      s = a * 3.0;
      a *= 2.0;
      for(i = 0;i < 4;i++){
        a /= 3.0; s += a;
        a *= 2.0; s += a;
      }
      out.println(s);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 19248
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

ll const MAX = 1e5 + 5;
vll children[MAX];
vll G[MAX];
ll parent[MAX] = {};
vll ord;
ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
	return (x + y + 2 * MOD) % MOD;
}
ll mod_m(ll x, ll y) {
	return x * y%MOD;
}
void dfs(ll n) {
	parent[1] = 1;
	stack<ll> st;
	st.push(1);
	ord.push_back(1);
	while (!st.empty()) {
		ll cur = st.top();
		st.pop();
		for (auto nex : G[cur]) {
			if (parent[nex] == 0) {
				parent[nex] = cur;
				children[cur].push_back(nex);
				st.push(nex);
				ord.push_back(nex);
			}
		}
	}
}

ll dp[MAX][2];

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n - 1) {
		ll x, y;
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(n);
	PER(i, n - 1, 0) {
		ll cur = ord[i];
		if (SIZE(children[cur]) == 0) {
			dp[cur][0] = dp[cur][1] = 1;
		}
		else {
			ll black = 1; ll white = 1;
			for (auto chi : children[cur]) {
				black = mod_m(black, dp[chi][1]);
				white = mod_m(white, mod_p(dp[chi][0], dp[chi][1]));
			}
			dp[cur][0] = black;
			dp[cur][1] = white;
		}
	}
	cout << mod_p(dp[1][0] , dp[1][1]) << endl;
}

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

int main() {
  int s, w;
  cin >> s >> w;
  cout << (w >= s ? "unsafe" : "safe") << endl;
  return 0;
}

Measured memory_bytes: 3620
//19
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int w,h;cin>>w>>h,w|h;){
    char g[30][30];
    int c[30][30];
    for(int y=0;y<h;y++){
      for(int x=0;x<w;x++){
	cin>>g[y][x];
	c[y][x]=(g[y][x]=='N')?0:
	  (g[y][x]=='E')?1:
	  (g[y][x]=='S')?2:
	  (g[y][x]=='W')?3:-1;
      }
    }
    int t;
    for(t=0;t<=180;t++){
      int dy[]={-1,0,1,0};
      int dx[]={0,1,0,-1};
      bool p=false;
      for(int y=0;y<h;y++){
	for(int x=0;x<w;x++){
	  if(c[y][x]!=-1){
	    p=true;
	    for(int i=0;i<4;i++){
	      int nd=(c[y][x]+5-i)%4;
	      int ny=y+dy[nd];
	      int nx=x+dx[nd];
	      if((g[ny][nx]!='#')&&c[ny][nx]==-1){
		c[y][x]=nd;
		break;
	      }
	    }
	  }
	}
      }
      if(!p)break;
      int n[30][30];
      copy(c[0],c[30],n[0]);
      for(int d=0;d<4;d++){
	for(int y=0;y<h;y++){
	  for(int x=0;x<w;x++){
	    if(c[y][x]==3-d){
	      int ny=y+dy[3-d];
	      int nx=x+dx[3-d];
	      if((g[ny][nx]!='#')&&c[ny][nx]==-1&&n[ny][nx]==-1){
		n[ny][nx]=3-d;
		n[y][x]=-1;
	      }
	    }
	  }
	}
      }
      for(int y=0;y<h;y++){
	for(int x=0;x<w;x++){
	  if(g[y][x]=='X'){
	    n[y][x]=-1;
	  }
	}
      }
      copy(n[0],n[30],c[0]);
    }
    if(t<=180){
      cout<<t<<endl;
    }else{
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

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

const int SIZE = 2e5+10;
int n;
int a[SIZE], b[SIZE], l[SIZE], r[SIZE];

inline int read()
{	
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)){x=x*10+(ch-'0'); ch=getchar();}
	return x;
}

int main()
{
	int l = SIZE, r = 0, c = 0;
	n=read();
	for (int i = 1; i <= n; ++i) a[i]=read();
	for (int j = 1; j <= n; ++j) b[j]=read();
	for (int i = 1; i <= (n>>1);++i) swap(b[i], b[n-i+1]);
	for (int i = 1; i <= n; ++i)
		if (a[i] == b[i]) { r = i; if (l > n) l = i;}
	for (int i = 1; i <= n; ++i)
		if (a[i] != a[r] && b[i] != a[r]) ++c;
	if (c < r - l + 1) printf("No\n");
	else
	{
		printf("Yes\n");
		for (int i = 1; i <= n; ++i)
		{
			if (l > r) break;
			if (a[i] != a[l] && b[i] != a[l]) swap(b[i], b[l++]);
		}
		for (int i = 1; i <= n; ++i) printf("%d ", b[i]);
	}
	return 0;
}

Measured memory_bytes: 5304
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	var a []int
	for i := 0; i < n; i++ {
		var t int
		fmt.Scanf("%d", &t)
		a = append(a, t)
	}
	sort.Sort(sort.IntSlice(a))
	ans := math.MaxInt32
	for i := 0; i < (n - k + 1); i++ {
		d := a[i+k-1] - a[i]
		if ans > d {
			ans = d
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10Lf\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  long double ans=0;
  rep(i,n) {
    long double x;
    string s;
    cin >> x >> s;
    if(s=="JPY") ans+=x;
    else ans+=x*380000;
  }
  pd(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 2e5 + 5;

ll ans[maxn];
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n; vector<ll>a(n); ll k; cin >> k;
	for (ll i = 0; i < n; i++) cin >> a[i];
	sort(all(a));
	ll ans = 1;
	ll sm = 0;
	for (ll i = 0; i < n - 1; i++) sm += a[i];
	if (sm <= k) {
		cout << a[n - 1] + sm;
		return 0;
	}
	else {
		sm += a[n - 1];
		for (ll d = 2; d * d <= sm; d++) {
			if (sm % d) continue;
			bool f1 = 0, f2 = 0;
			vector<ll>xd;
			for (ll i = 0; i < n; i++) {
				xd.push_back(a[i] % d);
			}
			sort(all(xd));
			ll kek = -1;
			vector<ll>pref(n), suf(n);
			for (ll i = 0; i < n; i++) pref[i] = xd[i] + (i ? pref[i - 1] : 0);
			for (ll i = n - 1; i >= 0; i--) suf[i] = xd[i] + (n - 1 - i ? suf[i + 1] : 0);
			if (pref[n - 1] == 0) {
				f1 = true;
			}
			else {
				for (ll i = 0; i < n - 1; i++) {
					if (pref[i] == d * (n - i - 1) - suf[i + 1]) {
						kek = pref[i];
						break;
					}
				}
				if (kek != -1) {
					if (kek <= k) {
						f1 = true;
					}
				}
			}
			ll dd = sm / d;
			xd.clear();
			for (ll i = 0; i < n; i++) {
				xd.push_back(a[i] % dd);
			}
			sort(all(xd));
			kek = -1;
			pref.clear(), suf.clear();
			pref.resize(n), suf.resize(n);
			for (ll i = 0; i < n; i++) pref[i] = xd[i] + (i ? pref[i - 1] : 0);
			for (ll i = n - 1; i >= 0; i--) suf[i] = xd[i] + (n - 1 - i ? suf[i + 1] : 0);
			if (pref[n - 1] == 0) {
				f2 = true;
			}
			else {
				for (ll i = 0; i < n - 1; i++) {
					if (pref[i] == dd * (n - i - 1) - suf[i + 1]) {
						kek = pref[i];
						break;
					}
				}
				if (kek != -1) {
					if (kek <= k) {
						f2 = true;
					}
				}
			}
			if (f1) {
				ans = max(ans, d);
			}
			if (f2) {
				ans = max(ans, dd);
			}
		}
	}
	cout << ans;
	return 0;

}
/*

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int n, k;
    cin >> n >> k;
    vector<ll> H(n);
    REP(i, n)
    cin >> H[i];

    sort(H.begin(), H.end(), greater<ll>());

    ll ans = 0;
    for (ll i = k; i < n; i++)
    {
        ans += H[i];
    }

    Cout(ans);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n; bool f = false;
	ll l[100002], r[100002]; ll t;
	int usedl[100002] = {}; int usedr[100002] = {};
	cin >> n;
	l[0] = 0; r[n + 1] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> t;
		if (l[i - 1] < t) {
			usedl[i] = 1;
		}
		l[i] = max(t, l[i]);
	}
	ll x[100002] = {};
	for (int i = 1; i <= n; i++) {
		cin >> t; x[i] = t;
	}
	for (int i = n; i >= 1; i--) {
		t = x[i];
		if (r[i + 1] < t) {
			usedr[i] = 1;
		}
		r[i] = max(t, r[i+1]);
	}
	ll sum = 1;
	for (int i = 1; i <= n; i++) {
		if (usedl[i] == 0 && usedr[i] == 0)sum = sum*min(r[i],l[i])%MOD;
		if (usedl[i] == 1&&l[i]>r[i])f = true;
		if (usedr[i] == 1 && l[i] < r[i])f = true;
	}
	if (f)cout << 0 << endl;
	else cout << sum << endl;
	char nyaa;
	std::cin >> nyaa;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 200000

signed main() {
    int n;
    cin >> n;
    int x[n], y[n];
    char u[n];
    rep(i, n) {
        cin >> x[i] >> y[i] >> u[i];
    }
    int ans = INF;
    // UD
    {
        set<int> D[MAX + 1];
        rep(i, n) {
            if (u[i] == 'D') D[x[i]].emplace(y[i]);
        }
        rep(i, n) {
            if (u[i] != 'U') continue;
            auto itr = D[x[i]].lower_bound(y[i]);
            if (itr == D[x[i]].end()) continue;
            ans = min(ans, (*itr - y[i]) * 5);
        }
    }
    // RL
    {
        set<int> L[MAX + 1];
        rep(i, n) {
            if (u[i] == 'L') L[y[i]].emplace(x[i]);
        }
        rep(i, n) {
            if (u[i] != 'R') continue;
            auto itr = L[y[i]].lower_bound(x[i]);
            if (itr == L[y[i]].end()) continue;
            ans = min(ans, (*itr - x[i]) * 5);
        }
    }
    // UR
    {
        set<int> U[MAX * 2 + 1];
        rep(i, n) {
            if (u[i] == 'U') U[y[i] + x[i]].emplace(x[i]);
        }
        rep(i, n) {
            if (u[i] != 'R') continue;
            auto itr = U[y[i] + x[i]].lower_bound(x[i]);
            if (itr == U[y[i] + x[i]].end()) continue;
            ans = min(ans, (*itr - x[i]) * 10);
        }
    }
    // UL
    {
        set<int> L[MAX * 2 + 1];
        rep(i, n) {
            if (u[i] == 'L') L[y[i] - x[i] + MAX].emplace(x[i]);
        }
        rep(i, n) {
            if (u[i] != 'U') continue;
            auto itr = L[y[i] - x[i] + MAX].lower_bound(x[i]);
            if (itr == L[y[i] - x[i] + MAX].end()) continue;
            ans = min(ans, (*itr - x[i]) * 10);
        }
    }
    // RD
    {
        set<int> D[MAX * 2 + 1];
        rep(i, n) {
            if (u[i] == 'D') D[y[i] - x[i] + MAX].emplace(x[i]);
        }
        rep(i, n) {
            if (u[i] != 'R') continue;
            auto itr = D[y[i] - x[i] + MAX].lower_bound(x[i]);
            if (itr == D[y[i] - x[i] + MAX].end()) continue;
            ans = min(ans, (*itr - x[i]) * 10);
        }
    }
    // DL
    {
        set<int> L[MAX * 2 + 1];
        rep(i, n) {
            if (u[i] == 'L') L[y[i] + x[i]].emplace(x[i]);
        }
        rep(i, n) {
            if (u[i] != 'D') continue;
            auto itr = L[y[i] + x[i]].lower_bound(x[i]);
            if (itr == L[y[i] + x[i]].end()) continue;
            ans = min(ans, (*itr - x[i]) * 10);
        }
    }
    if (ans != INF)
        cout << ans << endl;
    else
        cout << "SAFE" << endl;
    return 0;
}

Measured memory_bytes: 33364
DBG = !true
n,k = gets.split.map{|x| x.to_i}
td = []
for i in 0...n
  tt,dd = gets.split.map{|x| x.to_i}
  td << [tt,dd]
end

# おいしさでソート
td.sort_by!{|z| -z[1]}
if DBG
  print td
  puts ""
end

# ネタ種類ごと
tt = td.map{|z| z[0]}.uniq
h = {}
hmax = {}
for t in tt
  h[t] = []
  hmax[t] = 0
end
for i in 0...n
  t = td[i][0]
  d = td[i][1]
  h[t] << d
  hmax[t] = d if d > hmax[t]
end
if DBG
  print h
  puts ""
  print hmax
  puts ""
end

# おいしさの上位K個
donly = td[0,k].map{|z| z[1]}.inject(:+)
puts "#{donly}" if DBG

# そこに入らないネタ(t)の上位各１個ずつ
usedts = td[0,k].map{|z| z[0]}.uniq
unusedts = tt - usedts
unusedtval = unusedts.map{|t| hmax[t]}
unusedtval.sort_by!{|v| -v}

# 使った寿司
usedset = {}
for t in tt
  usedset[t] = []
end
for td0 in td[0,k]
  t = td0[0]
  d = td0[1]
  usedset[t] << d
end

# 各ネタ種類の、最大値のものをマーク（入れ替えない）
marked = {}
for i in 0...n
  t = td[i][0]
  d = td[i][1]
  if !marked.has_key?(t) && d == hmax[t]
    marked[t] = i
  end
end
if DBG
  print "marked: "
  print marked
  puts ""
  print "usedts: "
  print usedts
  puts ""
  print "unusedtval: "
  print unusedtval
  puts ""
end

# おいしさが下のから１個ずつ、違う種類に入れ替えていく
nkind = usedts.size
maxval = donly + nkind*nkind
curval = donly
(k-1).downto(1) { |i|
  break if unusedtval.empty?
  t = td[i][0]
  d = td[i][1]
  if i != marked[t]
    nkind += 1
    v = unusedtval.shift
    curval += v - d
    curvalx = curval + nkind*nkind
    maxval = curvalx if curvalx > maxval
  end
}
puts "#{maxval}"


Measured memory_bytes: 43980
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
int main(){
  int A,B,K;
  cin >> A >> B >> K;

  int n;
  for(n=min(A,B); n>=1; n--){
    if(A%n==0 && B%n==0){
      K--;
      if(K==0){
        cout << n <<endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

long long A[100005];
long long B[100005];

int main()
{
    long long N;

    cin >> N;

    long long ans = 0;

    for (long long i = 0; i < N;i++)
    {
        cin >> A[i] >> B[i];
    }

    for (long long i = N - 1; i >= 0;i--)
    {
        if((ans + A[i]) % B[i] != 0)
        {
            ans += B[i] - (ans + A[i]) % B[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int a,b,i,j;
	int s,min,min2;
	
	min=2000;
	min2=2000;
	for(i=0;i<3;i++){
		scanf("%d",&a);
		if(min>a){
			min=a;
		}
	}
	for(j=0;j<2;j++){
		scanf("%d",&b);
		if(min2>b){
			min2=b;
		}
	}
//	printf("min=%d %d\n",min,min2);
	s=min+min2-50;
	printf("%d\n",s);
	return 0;	
}

	

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int A,P;
  cin>>A>>P;
  cout<<(A*3+P)/2<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;

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


int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll a,b,n;
 	cin>>a>>b>>n;
 	ll ans=0;
 	ll chk=min(b-1,n);
 	if(n>b-1)
 	{
 		ll rem=(n-(b-1))/b;
 		chk=(b-1)+rem*b;
 	}
 	ll fll = (a*chk);
 	fll/=b;
 	ll frr = (chk/b);
 	frr*=a;
 	cout<<fll-frr<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x; cin>>x;
	if (x==7||x==5||x==3) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 65536

int main(){
  int i,j,k,m;
  int a[N],b[N];
  i=0;
  while(1){
    scanf("%d %d",&j,&k);
    a[i] = j;
    b[i] = k;
    if(j==0 && k==0){
      break;
    }
    i++;
  }
  for(m=0;m<i;m++){
    if(a[m]<b[m]){
      printf("%d %d\n",a[m],b[m]);
    }else{
      printf("%d %d\n",b[m],a[m]);
    }
  }
  return 0;
}

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

N = int(input())
X = input()
D = int(input())

ans = list(X)
done = [False] * N
for i in range(N):
    if D == 0:
        break
    if ans[i] == "0":
        ans[i] = "1"
        done[i] = True
        D -= 1

for i in range(N)[::-1]:
    if D == 0:
        break
    if ans[i] == "1" and not done[i]:
        ans[i] = "0"
        D -= 1

print("".join(ans))

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

int main(){
  int N,tmp;
  vector<int> d;
  map<int,int> M;

  cin >> N;
  for(int i=0;i<N;i++){
    cin >> tmp;
    d.push_back(tmp);
  }

  for(int i=0;i<N;i++){
    if(M.count(d.at(i))>0)
      M.at(d.at(i))++;
    else
      M[d.at(i)] = 1;
  }

  cout << M.size() << endl;

}


Measured memory_bytes: 3644
import java.util.Scanner;
class Main{   
 public void yatary() {  
      Scanner sc = new Scanner(System.in); 
     int a;
     int b;
     int d;
     int r;
     double f;
     a = sc.nextInt();
     b = sc.nextInt();
     d = a/b;
     r = a%b;
     f = a*1.0/b;
     System.out.printf("%d %d %7f",d,r,f);
     }
public static void main(String[] args){ 
    new Main().yatary();    
}
} 

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

using namespace std;

typedef long long LL;

LL a, b, k;

int main()
{
    cin >> a >> b >> k;
    if(k <= a)
    {
        cout << a - k << ' ' << b << endl;
        return 0;
    }
    k -= a;
    cout << 0 << ' ' << max(0LL, b - k) << endl;
    return 0;
}


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

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

    //write your code here
		int n;
		cin>> n;
		vector<vector<int> > v(n, vector<int > (3,0));
		for(int i=0;i<n;i++){
			cin>> v[i][0]>> v[i][1]>> v[i][2];
		}
		vector<vector<int> > dp(n, vector<int > (3,0));
		dp[0][0] = v[0][0];
		dp[0][1] = v[0][1];
		dp[0][2] = v[0][2];
		for(int i=1;i<n;i++){
			dp[i][0]= max(dp[i-1][1], dp[i-1][2]) + v[i][0];
			dp[i][1]= max(dp[i-1][0], dp[i-1][2]) + v[i][1];
			dp[i][2]= max(dp[i-1][0], dp[i-1][1]) + v[i][2];
		}
		cout<<*max_element(dp[n-1].begin(), dp[n-1].end())<<endl;
    return 0;
}


Measured memory_bytes: 11264
#include <cstdio>

using namespace std;

int main(){
    int x;
    scanf("%d", &x);
    int n = x / 100;
    int res = -1;;
    if(x % 100 <= n*5){
        res = 1;
    }else{
        res = 0;
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main(){
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int ans = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ans = max(abs(v.at(i) - v.at(j)), ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n;
ll ans;
int cnt[10][10][10][10];
string s;
pair<int,int> counter(ll x)
{
    int two=0, five=0;
    while(x%2==0)
        x/=2, two++;
    while(x%5==0)
        x/=5, five++;
    return {min(two,9),min(five,9)};
}
int solve(int a, int b, int c, int d)
{
    int cur=0;
    for(int x1=0; x1<=9; x1++)
        for(int x2=0; x2<=9; x2++)
            for(int y1=0; y1<=9; y1++)
                for(int y2=0; y2<=9; y2++)
                    cur+=cnt[x1][x2][y1][y2]*(x1>=c && x2>=d && a>=y1 && b>=y2);
    return cur;
}
int main()
{
    IO
    cin>>n;
    while(n--)
    {
        cin>>s;
        ll x=0, y=1;
        int good=0;
        for(auto i : s)
        {
            if(i=='.')
            {
                good=1;
                continue;
            }
            x=x*10+i-'0';
            if(good)
                y*=10;
        }
        ll g=__gcd(x,y);
        x/=g, y/=g;
        if(y==1)
            ans--;
        pair<int,int> p1 =counter(x);
        pair<int,int> p2 =counter(y);
        cnt[p1.first][p1.second][p2.first][p2.second]++;
    }
    for(int x1=0; x1<=9; x1++)
        for(int x2=0; x2<=9; x2++)
            for(int y1=0; y1<=9; y1++)
                for(int y2=0; y2<=9; y2++)
                    ans+=1LL*solve(x1,x2,y1,y2)*cnt[x1][x2][y1][y2];
    cout<<ans/2;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll K,S;
    cin >> K >> S;
    ll ans = 0;
    rep(i,0,K+1){
        rep(j,0,K+1){
            int num = S - i - j;
            if(num >= 0 && num <= K)ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
i = 0
p1 = 0
p2 = 0
p3 = 0
p4 = 0
for _ in range(n):
    if x[i] > y[i]:
        p1 = (x[i] - y[i]) + p1
    else:
        p1 = (y[i] - x[i]) + p1
    i = i + 1
print('{:.8f}'.format(p1))

i = 0
for _ in range(n):
    p2 = ((x[i] - y[i]))**2 + p2
    i = i + 1
print('{:.8f}'.format(p2**(1/2)))

i = 0
for _ in range(n):
    if x[i] > y[i]:
        p3 = ((x[i] - y[i]))**3 + p3
    else:
        p3 = ((y[i] - x[i]))**3 + p3
    i = i + 1
print('{:.8f}'.format(p3**(1/3)))

i = 0
M = 0
for _ in range(n):
    if x[i] > y[i]:
        p4 = x[i] - y[i]
        if M < p4:
            M = p4
    else:
        p4 = y[i] - x[i]
        if M < p4:
            M = p4
    i = i + 1
print('{:.8f}'.format(M))


Measured memory_bytes: 5656
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
int MOD=1000000000+7;
int INF=1e6;

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

int p[300000],n,pos[300000];
int LIS(){
    int temp=1;
    int ans=0;
    while(temp<n+1){
        int pre=temp;
        while(pos[temp]<pos[temp+1]){
            temp++;
        }
        ans=max(ans,temp-pre+1);
        temp++;
    }
    return ans;
}

main(){
    cin>>n;
    rep(i,n){
        cin>>p[i];
        pos[p[i]]=i;
    }
    cout<<n-LIS();
}

Measured memory_bytes: 1920
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define M 605

int dis[M][M], color[M];

using namespace std;

bool bfs(int s, int n)
{
	queue<int> q;
	q.push(s);
	color[s] = 1;
	while (!q.empty())
	{
		int from = q.front();
		q.pop();
		for (int i = 1; i <= n; i++)
		{
			if (dis[from][i] != (int)1e9 && color[i] == -1)
			{
				q.push(i);
				color[i] = !color[from];									//染成不同的颜色   
			}
			if (dis[from][i] != (int)1e9 && color[from] == color[i])		//颜色有相同，则不是二分图   
				return false;
		}
	}
	return true;
}

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

	for (int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		for (int j = 0; j < n; j++)
		{
			if (s[j] == '1')
				dis[i][j + 1] = 1;
			else
				dis[i][j + 1] = (int)1e9;
		}
	}

	memset(color, -1, sizeof(color));

	bool flag = false;
	for (int i = 1; i <= n; i++)
		if (color[i] == -1 && !bfs(i, n))
		{
			cout << -1 << endl;
			return 0;
		}

	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);

	int maxl = -1;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
		{
			if (dis[i][j] == 1e9)
			{
				cout << -1 << endl;
				return 0;
			}
			maxl = max(maxl, dis[i][j]);
		}

	cout << maxl + 1 << endl;

	return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    int s = 0;
    for (int i = 0; i < m; i++) {
        int a; cin >> a;
        s += a;
    }
    cout << max(-1, n - s) << endl;
    return 0;
}


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

using namespace std;
bool b[102];

int main()
{
    int x,n,value;
    cin>>x>>n;
    int a[n];
    memset(b,true,sizeof(b));

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]]=false;
    }
    if(b[x]==true)
    {
        cout<<x<<endl;
        return 0;
    }
    int mx=INT_MAX;
    for(int i=0;i<102;i++)
    {
        if(b[i]==true)
        {
            if(mx>abs(x-i))
            {
                mx=abs(x-i);
                value=i;
            }
        }
    }
    cout<<value<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char cd[15];
    int a,b,i,s,cnt=0;
    cin>>a>>b;
    s=a+b+1;
    cin>>cd;
    for(i=0;i<a;i++) {
        if(cd[i]>='0' && cd[i]<='9') cnt++;
    }
    if(cd[a]=='-') cnt++;
    for(i=a+1;i<s;i++) {
        if(cd[i]>='0' && cd[i]<='9') cnt++;
    }
    if(cnt==s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;

    int x[n], y[n];
    long long int d, D1 = 0, D2 = 0, D3 = 0, Dmax = -1;

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

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


    for (int i = 0; i < n; i++) {
        if (x[i] > y[i]) {
            d = x[i] - y[i];
        } else {
            d = y[i] - x[i];
        }

        D1 += d;
        D2 += d * d;
        D3 += d * d * d;

        if (Dmax < d) {
            Dmax = d;
        }    
    }

    double d1, d2, d3, dmax;
    d1 = (double)D1;
    d2 = sqrt((double)D2);
    d3 = pow((double)D3, 1.0/3);
    dmax = (double)Dmax;

    cout << fixed << setprecision(10) << d1 << endl;
    cout << fixed << setprecision(10) << d2 << endl;
    cout << fixed << setprecision(10) << d3 << endl;
    cout << fixed << setprecision(10) << dmax << endl;

    return 0;
}



Measured memory_bytes: 3448
//
// tested with : g++ (GCC) 8.3.0
//

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int s;//3桁の番号(110)
    cin >> s;

    int result = 0;
    int count = 0;
    for (int i = 0; i < 3; i++) {
        result = s % 10;//一番下の値が得られる。
        if (result == 1) {
            count++;
        }
        s = s / 10;//一番下の値を削る。
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
#define DEBUG(x) cerr << '>' << #x << ':' << x << endl;
#define ll long long int
#define endl '\n'
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef queue<int> qii;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define all(x) x.begin(),x.end()
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
const ll inf = 2e18+11;
double pi = 2 * acos(0.0); 
 
void solve(){
    int n;
    cin>>n;
    int a[n];
    ll s=0;
    mii m;
    rep(i,0,n) cin>>a[i],s+=a[i],m[a[i]]++;
    int q,b,c;
    cin>>q;
    while(q--){
        cin>>b>>c;
        s-=((ll)m[b]*(ll)b);
        s+=((ll)m[b]*(ll)c);
        m[c]+=m[b];
        m[b]=0;
        cout<<s<<'\n';
    }
}
 
int main(){ 
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

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

int main() {
    bool cards[4][14];
    int n, rank;
    char suit;
    
    for (int s = 0; s < 4; s++) 
        for (int r = 1; r <= 13; r++) 
            cards[s][r] = 0;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> suit >> rank;
        if(suit == 'S') cards[0][rank] = 1;
        if(suit == 'H') cards[1][rank] = 1;
        if(suit == 'C') cards[2][rank] = 1;
        if(suit == 'D') cards[3][rank] = 1;
    }
    
    for (int s = 0; s < 4; s++) {
        for(int r = 1; r <= 13; r++) {
            if(cards[s][r]) continue;
            if(s == 0) suit = 'S';
            if(s == 1) suit = 'H';
            if(s == 2) suit = 'C';
            if(s == 3) suit = 'D';
            cout << suit << " " << r << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3072
N, M = map(int, input().split())
arr = list(map(lambda x: int(x)*(-1), input().split()))
import heapq
heapq.heapify(arr)
for _ in range(M):
    tmp = heapq.heappop(arr)
    heapq.heappush(arr,-(-tmp//2))
print(-sum(arr))

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

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

  string ans = "No";
  int len = 0;
  for ( int i = 0; i < n; i++ ) {
    int x, y;
    cin >> x >> y;
    if ( x == y ) { len++; } else { len = 0; }
    if ( len == 3 ) { ans = "Yes"; }
  }

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


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextInt();
		long y = sc.nextInt();
		long a = 1000000000;
		a = a * a;
		long z;
		boolean e = false;
		if (x != y && x % y != 0) {
			int i = (int)(y / x);
			for (; x*i <= a; i++) {
				z = x * i;
				if ((z % y) != 0) {
					System.out.println(z);
					e = true;
					break;
				}
			}
		}
		if (!e)
			System.out.println("-1");
	}
}


Measured memory_bytes: 21844
package main

import (
	"fmt"
)

func main() {
	var n int
	var items []string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a string
		fmt.Scan(&a)
		items = append(items, a)
	}

	tmp := map[string]bool{}
	result := make([]string, 0)
	for _, a := range items {
		if !tmp[a] {
			tmp[a] = true
			result = append(result, a)
		}
	}

	fmt.Println(len(result))
}


Measured memory_bytes: 30916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 main(){
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll dx = x2 - x1;
    ll dy = y2 - y1;
    ll x3 = x2 - dy;
    ll y3 = y2 + dx;
    ll x4 = x3 - dx;
    ll y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const ll MOD = 1e9+7;
int n, m;
int a[100010];
int b[100010];
vector<int> G[100010];
int par[100010];
map<int,int> mp;

int main(){
//  ios::sync_with_stdio(false);
//  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n+m-1; i++) {
    cin >> a[i] >> b[i];
    mp[b[i]]++;
    G[a[i]].push_back(b[i]);
  }
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (mp.count(i) == 0) {
      q.push(i);
      break;
    }
  }
  while (!q.empty()) {
    int tp = q.front();
    q.pop();
    for (int i = 0; i < G[tp].size(); i++) {
      int next = G[tp][i];
      mp[next]--;
      if (mp[next] == 0) {
        par[next] = tp;
        q.push(next);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << par[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 12160