akhauriyash/Code-Regression huggingface dataset:
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const LL mod=1e9+7,inf=1LL<<60;
struct Node{
	LL x,y,c,next;
}a[400010];LL len=0,last[100010];
LL n,m,st,ed,f[2][100010];
struct node{
	LL x,d;
	node() {}
	node(LL a,LL b) {x=a;d=b;}
};
bool operator < (node a,node b) {return a.d>b.d;}
priority_queue<node> q;
void ins(LL x,LL y,LL c)
{
	a[++len].x=x;a[len].y=y;a[len].c=c;
	a[len].next=last[x];last[x]=len;
}
bool vis[100010];
LL dis[2][100010];
void dij(LL op,LL st)
{
	for(LL i=1;i<=n;i++) dis[op][i]=inf;
	memset(vis,false,sizeof(vis));
	dis[op][st]=0;q.push(node(st,0));
	while(!q.empty())
	{
		LL x=q.top().x;q.pop();
		if(vis[x]) continue;
		vis[x]=true;
		for(LL i=last[x];i;i=a[i].next)
		{
			LL y=a[i].y;
			if(dis[op][y]>dis[op][x]+a[i].c)
			{
				dis[op][y]=dis[op][x]+a[i].c;
				q.push(node(y,dis[op][y]));
			}
		}
	}
}
void solve(LL op,LL st)
{
	memset(vis,false,sizeof(vis));
	f[op][st]=1;
	q.push(node(st,dis[op][st]));
	while(!q.empty())
	{
		LL x=q.top().x;q.pop();
		if(vis[x]) continue;
		vis[x]=true;
		for(LL i=last[x];i;i=a[i].next)
		{
			LL y=a[i].y;
			if(dis[op][x]+a[i].c==dis[op][y])
			{
				(f[op][y]+=f[op][x])%=mod;
				q.push(node(y,dis[op][y]));
			}
		}
	}
}
LL get(LL x,LL y) {return f[0][x]*f[0][x]%mod*f[1][y]%mod*f[1][y]%mod;}
int main()
{
	scanf("%lld %lld %lld %lld",&n,&m,&st,&ed);
	for(LL i=1;i<=m;i++)
	{
		LL x,y,c;scanf("%lld %lld %lld",&x,&y,&c);
		ins(x,y,c);ins(y,x,c);
	}
	dij(0,st);dij(1,ed);
	solve(0,st);solve(1,ed);
	LL ans=f[0][ed]*f[1][st]%mod;
	for(int i=1;i<=n;i++) if(dis[0][i]==dis[1][i]&&dis[0][i]+dis[1][i]==dis[0][ed]) (ans-=get(i,i))%=mod;
	for(LL i=1;i<=len;i+=2)
	{
		LL x=a[i].x,y=a[i].y;
		if(dis[0][x]>dis[0][y]) swap(x,y);
		if(dis[0][x]+dis[1][y]+a[i].c==dis[0][ed]&&abs(dis[0][x]-dis[1][y])<a[i].c)
			(ans-=get(x,y))%=mod;
	}
	printf("%lld",(ans+mod)%mod);
}

Measured memory_bytes: 18416
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  cout<<a.at(n-1)-a.at(0)<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <tuple>
using namespace std;
 
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double eps = 1e-8;
 
#define INF 2147483647
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define FILL(v,n) memset(v,n,sizeof(v))
#define EB emplace_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rep1n(i,n) for(int i=1;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie();cout.tie();
 
#define MXN 1000000 //10^6

int main(){
    int n, a, b, c;
    vector<int> v[3];
    
    cin>>n;
    rep(i,3)
        v[i].resize(n+1, 0);
    rep1(i,n){
        cin>>a>>b>>c;
        v[0][i] = max(v[1][i-1] + a, v[2][i-1] + a);
        v[1][i] = max(v[0][i-1] + b, v[2][i-1] + b);
        v[2][i] = max(v[0][i-1] + c, v[1][i-1] + c);
        
    }
    cout<<max(v[0][n], max(v[1][n], v[2][n]));
    
    
}







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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};


const int SZ = 412345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}
ll H(int n, int r) {
  return choose(n+r-1, r);
}

int main2() {
  int N = nextInt();
  int K = nextInt();
  K = min(K, N);

  mint ans = 0;
  for (int z = 0; z <= K; z++) {
    int P = N - z;
    if (P == 0) continue;
    ans += choose(N, z) * H(N-z, z);
  }
  cout << ans.x << endl;
  return 0;
}

int main() {

{
  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;
}


#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll mn = min(min(a,b),tmin(c,d,e));
    cout << (n+mn-1)/mn+4 << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

if k == 0:
  print(n**2)
  exit()
    
ans = 0
for b in range(k+1, n+1):
  p = n//b
  r = n%b
  
  ans += p*(b-k)
  ans += max(0, r-k+1)
print(ans)

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

int main(){
  	int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>21){cout << "bust" << endl;}
  if(a+b+c<22){cout << "win" << endl;}
  
  
  
	return 0;
}

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

cost1 = 0

for i in range(X, N+1):
  if i in A:
    cost1 += 1

cost2 = 0

for i in range(X, 0, -1):
  if i in A:
    cost2 += 1

print(min(cost1, cost2))

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
int n,m,k,cnt,ans,sum,a[7][7],b[7][7],red[15];
void dfs(int x)
{
	if(x==n+m+1)
	{
		sum=0;
		for(int i=1;i<=n;i++)
			for(int l=1;l<=m;l++)
				b[i][l]=a[i][l];
		for(int i=1;i<=cnt;i++)
			if(red[i]<=n)
			{
				for(int l=1;l<=m;l++)
					b[red[i]][l]=0;
			}
			else
			{
				for(int l=1;l<=n;l++)
					b[l][red[i]-n]=0;
			}
		for(int i=1;i<=n;i++)
			for(int l=1;l<=m;l++)
				sum+=b[i][l];
		if(sum==k)
			ans++;
		return ;
	}
	dfs(x+1);
	red[++cnt]=x;
	dfs(x+1);
	cnt--;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		for(int l=0;l<m;l++)
			if(s[l]=='#')
				a[i][l+1]=1;
	}
	dfs(1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
a=list(map(int,input().split()))+list(map(int,input().split()))+list(map(int,input().split()))
n=int(input())
b=[int(input()) for _ in range(n)]

open=[]
for i in range(n):
    if b[i] in a:
        open.append(a.index(b[i]))

correct=[{0,1,2},{3,4,5},{6,7,8},{2,5,8},{1,4,7},{0,3,6},{0,4,8},{2,4,6}]

for i in correct:
    if i <= set(open):
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 9116
#import<map>
long h,w,a,b,c,d,t[10],i;std::map<long,int>m;main(){for(*t=(scanf("%d%d%*d",&h,&w)-h)*(2-w);~scanf("%d%d",&a,&b);i=0)for(;i<9;)if((c=a+i%3)>2&(d=b+i++/3)>2&c<=h&d<=w)t[c=m[c*w+d]++]--,t[c+1]++;for(;i<10;)printf("%ld ",t[i++]);}

Measured memory_bytes: 56448
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

    int len = s.size();
    cout << s[0] + to_string(len - 2) + s[len-1]  << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fr(i,j) for(int i=beg[j];i;i=nex[i])
using namespace std;
int const mn=1e5+3,mm=2e5+3,inf=1e9+7;
int n,rt,gra,beg[mn],to[mm],len[mm],nex[mm],size[mn],f[mn];
LL ans;
void ins(int u,int v,int w){
	to[++gra]=v;
	len[gra]=w;
	nex[gra]=beg[u];
	beg[u]=gra;
}
void dfs(int p,int q){
	size[p]=1;
	fr(i,p)if(to[i]!=q){
		dfs(to[i],p);
		ans+=2ll*len[i]*min(size[to[i]],n-size[to[i]]);
		size[p]+=size[to[i]];
		f[p]=max(f[p],size[to[i]]);
	}
	f[p]=max(f[p],n-size[p]);
}
int main(){
	scanf("%d",&n);
	fo(i,1,n-1){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		ins(u,v,w);
		ins(v,u,w);
	}
	rt=1;
	dfs(1,0);
	fo(i,2,n)if(f[i]<f[rt])rt=i;
	int mi=inf;
	fr(i,rt)if(f[to[i]]==f[rt]){
		printf("%lld",ans-len[i]);
		return 0;
	}else mi=min(mi,len[i]);
	printf("%lld",ans-mi);
	return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int r; cin >> r;
    r *= 2;
    cout << r * M_PI << endl;
    return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int32_t main(){
	int n; cin>>n;
	vector<int>v(n);
	int all=0;
	for(int i=0; i<n; i++){
		cin>>v[i]; all^=v[i];
	}
	for(int i=0; i<n; i++)
		cout<<(v[i]^all)<<(i==n-1?"\n":" ");
	return 0;
}

Measured memory_bytes: 3992
import math

a, b, C = map(float, input().split())

rad = C*math.pi/180
c = math.sqrt(a**2+b**2-2*a*b*math.cos(rad))

S = a*b*math.sin(rad)/2
L = a+b+c
h = b*math.sin(rad)

print(S)
print(L)
print(h)



Measured memory_bytes: 5692
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int N = Integer.parseInt(s);

            System.out.println(N < 1000 ? "ABC" : "ABD");
        }
    }
}


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

struct Team{
    string name;
    int id;
    int point;
    bool operator <(const Team& r) const{
        return point == r.point ? id < r.id : point > r.point;
    }
};


int main(){
    string name;
    int n, a, b, c, i = 0;
    while(cin >> n, n){
        if(i) cout << endl;
        vector< Team > v(n);
        for(i = 0; i < n; i++){
            cin >> name >> a >> b >> c;
            v[i].id = i;
            v[i].name = name;
            v[i].point = a * 3 + c;
        }
        sort(v.begin(), v.end());
        for(i = 0; i < n; i++){
            cout << v[i].name << "," << v[i].point << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
    using namespace std;
    #define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
    #define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
    #define ll long long int
    #define FF first
    #define SS second
    #define mp make_pair
    #define pb push_back
    #define pii pair<int,int>
    #define pll pair<long long int,long long int>
    #define sd(x) scanf("%d",&x)
    #define slld(x) scanf("%lld",&x)
    #define pd(x) printf("%d\n",x)
    #define plld(x) printf("%lld\n",x)
    #define pss printf
    #define MOD 1000000007
    #define INF 1e18
    #define eps 0.00001
    #define endl '\n'
    #define debug(n1) cout<<n1<<endl
    const int N = 1e5;  // limit for array size
    ll n;  // array size
     
    /*template<typename T>
    using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
     
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int rand(int l, int r){
        uniform_int_distribution<int> uid(l, r);
        return uid(rng);
    }
    */
    int main(){
        int a,b;cin>>a>>b;
      cout<<max(a+b,max(a-b,a*b))<<endl;
    	return 0;
    }

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

int main(){
    int n;
    cin >> n;
    vector<int> score(n, 0);
    for(int i=0; i<n*(n-1)/2; i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--; b--;
        if(c > d){
            score[a] += 3;
        }else if(c < d){
            score[b] += 3;
        }else{
            score[a]++;
            score[b]++;
        }
    }

    vector<pair<int,int>> ord(n);
    for(int i=0; i<n; i++){
        ord[i] = {-score[i], i};
    }
    sort(ord.begin(), ord.end());
    vector<int> ans(n);
    int curr = 0;
    for(int i=0; i<n; i++){
        if(i!=0 and ord[i].first!=ord[i-1].first){
            curr = i;
        }
        ans[ord[i].second] = curr+1;
    }
    for(int i=0; i<n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}



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

void maxHeapify(int *,int,int);
void buildMaxHeap(int *,int);

int main(){

  int i,H,*key;

  scanf("%d",&H);
  key=(int *)malloc(sizeof(int)*H);
  for(i=0;i<H;i++)scanf("%d",&key[i]);

  buildMaxHeap(key,H);

  for(i=0;i<H;i++)printf(" %d",key[i]);
  printf("\n");

  free(key);

  return 0;
}
void maxHeapify(int *key,int i,int H){

  int l,r,largest,tmp;

  l=2*(i+1)-1;
  r=2*(i+1);
  if(l<= H && key[l]>key[i]){
    largest=l;
  }else largest=i;
  if(r<=H && key[r]>key[largest]) largest=r;
  if(largest!=i){
    tmp=key[i];
    key[i]=key[largest];
    key[largest]=tmp;
    maxHeapify(key,largest,H);
  }
}
void buildMaxHeap(int *key,int H){
  int i;

  for(i=H/2-1;i>=0;i--){
    maxHeapify(key,i,H);
  }
}

Measured memory_bytes: 2472
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	int to, cost;
};

int main() {
	int n;
	cin >> n;
	cout << 0 << endl;
	string z;
	cin >> z;
	if (z == "Vacant") {
		return 0;
	}
	int head = -1;
	int tail = n;
	int tmp = 0;
	bool flag = true;
	/*
	if (n < 20) {
	FOR(i, 1, n) {
	cout << i << endl;
	string s;
	cin >> s;
	if (s == "Vacant") {
	return 0;
	}
	}
	}
	*/
	while (1) {
		int mid = (head + tail) / 2;
		cout << mid << endl;
		string s;
		cin >> s;
		if (s == "Vacant") {
			return 0;
		}
		if (s == z) {
			if (abs(tmp - mid) % 2 == 0) {
				if (flag) {
					head = mid;
				}
				else {
					tail = mid + 1;
				}
			}
			else {
				if (flag) {
					tail = mid + 1;
					flag = false;
				}
				else {
					head = mid;
					flag = true;
				}
			}
		}
		else {
			if (abs(tmp - mid) % 2 == 0) {
				if (flag) {
					tail = mid + 1;
					flag = false;
				}
				else {
					head = mid;
					flag = true;
				}
			}
			else {
				if (flag) {
					head = mid;
				}
				else {
					tail = mid + 1;
				}
			}
		}
		tmp = mid;
		z = s;
	}
}


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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
//}

int a,b,c,d,ans;
string s,t,u;

int main(){
  cin>>a>>b;
  a-=b;
  dump((a+(b-2))/(b-1)+1);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Q = sc.nextInt();
		int N = 100_001;
		boolean[] prime = new boolean[N+1];
		Arrays.fill(prime, true);
		prime[0] = prime[1] = false;
		for(int x = 4; x <= N; x+=2)
			prime[x] = false;
		for(int i = 3; i <= N; i+=2)
			if(prime[i])
				for(int x = i * 2; x <= N; x+=i)
					prime[x] = false;
		int[] S = new int[N];
		for(int i = 1; i < N; i++) {
			S[i] = S[i-1];
			if(i % 2 != 0 && prime[i] && prime[(i+1)/2])
				S[i]++;
		}
		for(int q = 0; q < Q; q++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(S[r] - S[l-1]);
		}
	}

}

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

/*ここからがmain関数*/
int main()
{
  int i, n;

  scanf("%d", &n);
  printf("%d\n", fibonacci(n));

  return 0;
}

/*fibonacci関数*/
int fibonacci(int n)
{
  int i;
  int data[45];

  data[0] = 1;
  data[1] = 1;

  for(i = 2; i <= n; i++)
    data[i] = data[i - 2] + data[i - 1];
  
  return data[n];
}











Measured memory_bytes: 2052
#include<iostream>
#include<map>

using namespace std;

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

	map<string,int> s;

	string x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		s.insert(make_pair(x, 0));
	}

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

	return 0;
}

Measured memory_bytes: 19228
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    vec an(5,0);
    rep(i,5) cin>>an[i];
    ll ans = 0,mini=10;
    rep(i,5){
        if(an[i]%10 != 0) mini = min(mini,an[i]%10);
        ans += (an[i]+9)/10;
    }
    --ans;
    ans *= 10;
    ans += mini;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s,r;
  cin>>s>>r;
  ll n=s.size();
  ll m=r.size();
  ll dp[n+1][m+1];
  ll i=0,j=0;
  for(i=0;i<=n;i++)
  {
    for(j=0;j<=m;j++)
    {
      if(i==0||j==0)
        dp[i][j]=0;
      else
        if(s[i-1]==r[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
      else
        if(s[i-1]!=r[j-1])
        dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    }
  }
  ll len=dp[n][m];
  //cout<<len<<"\n";
  /*for(i=0;i<=n;i++)
  {
    for(j=0;j<=m;j++)
      cout<<dp[i][j]<<" ";
    cout<<"\n";
  }*/
  i=n;
  j=m;
  string lcs="";
  while(i>0&&j>0)
  {
    //cout<<i<<" "<<j<<"\n";
    if(s[i-1]==r[j-1])
    {
      lcs+=s[i-1];
      j--;
      i--;
    }
    else
    if(dp[i-1][j]>dp[i][j-1])
      i--;
    else
      j--;
  }
  //cout<<i<<" "<<j<<"\n";
  reverse(lcs.begin(),lcs.end());
  cout<<lcs<<"\n";
}


Measured memory_bytes: 70656
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

int main() {

	int N, a, b, c, d;

	cin >> N;
	a = N - (N % 1000);
	b = N - a - (N % 100);
	c = N - a - b - (N % 10);
	d = N - a - b - c;
	a /= 1000;
	b /= 100;
	c /= 10;

	if (a + b + c + d == 7)cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a + b + c - d == 7)cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
	else if (a + b - c + d == 7)cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	else if (a + b - c - d == 7)cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
	else if (a - b + c + d == 7)cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a - b + c - d == 7)cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	else if (a - b - c + d == 7)cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	else cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

b = []
for i, j in enumerate(a):
    b += [i + 1] * j

for i in range(h):
    if i % 2 == 0:
        print(*b[i * w:i * w + w])
    else:
        print(*b[i * w:i * w + w][::-1])

Measured memory_bytes: 3828
n,m,x = map(int, input().split())
xl = [list(map(int, input().split())) for _ in range(n)]

ans = 10**7
for i in range(2 ** n):
    op = ["1"] * n  
    skl=[0]*m
    cost =0
    for j in range(n):
        if ((i >> j) & 1):
            op[n - 1 - j] = "0"
#買う本のパターン作成終了
    for k in range(0,n):
        if op[k]=="1":
            for l in range(1,m+1):
                skl[l-1] = skl[l-1]+xl[k][l]
            cost += xl[k][0]
    if min(skl)>=x:
        ans = min(ans,cost)

if ans == 10**7:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9228
//#include "SaveFuncs.cpp"

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

int Main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	rep(i, N)	cin >> H.at(i);

	int cont = 0, max = 0;
	for (int i = 1; i < N; i++)
	{
		if (H.at(i - 1) >= H.at(i))
		{
			cont++;
			chmax(max, cont);
		}
		else
		{
			cont = 0;
		}
	}

	cout << max;

	return 0;
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	Main();

	return 0;
}


Measured memory_bytes: 640
from math import sqrt, ceil


def square_like_factors(n):
  root_n = ceil(sqrt(n))
  for i in reversed(range(1, 1 + root_n)):
    if n % i == 0:
      return (i, n // i)
  return (1, n)


n = int(input())
a, b = square_like_factors(n)
print(a + b - 2)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,x) for(int i=0;i<x; i++)
typedef long long  ll;
using namespace std;
int main(){
  int X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  
  ll base_A[A],base_B[B],base_C[C];
  priority_queue<ll,vector<ll>,greater<ll>> p,q;
  priority_queue<ll>r;
    
  //push_back to priority_queue
  rep(i,A){
    cin>>base_A[i];
    p.push(base_A[i]);    
  }
  rep(i,B){
  	cin>>base_B[i];
    q.push(base_B[i]);
  }
  rep(i,C){
  	cin>>base_C[i];
    r.push((base_C[i]));
  }
  
  while(!(p.size()==X)){
    //cout<<p.top()<<endl;
  	p.pop();
  }
  while(!(q.size()==Y)){
    //cout<<q.top()<<endl;
  	q.pop();
  }
  
  int now_C = 0;
  
  while(1){
    if(now_C == C) break;
    
    if(p.top() < q.top()){	
      if(p.top() >= r.top()){
      	break;
      }else{
		p.pop();
        p.push(r.top());
        r.pop();
        now_C++;
      }
    }else {
      if(q.top() >= r.top()){
      	break;
      }else{
      	q.pop();
        q.push(r.top());
        r.pop();
        now_C++;
      }
    }
  }
  vector<ll> ansA(p.size()),ansB(q.size());
  ll ans=0;
  
  ll pS = p.size(),qS=q.size();
  
  rep(i,pS){
    ansA[i]=p.top();
    //cout<<p.top()<<endl;
    p.pop();
  }
  rep(i,qS){
    ansB[i]=q.top();
    //cout<<q.top()<<endl;
    q.pop();
  }
  
  for(int i=X-1; i>=0; i--){
  	ans+=ansA[i];
  }
  for(int i=Y-1; i>=0; i--){
  	ans+=ansB[i];
  }
  
  cout<<ans;
}


Measured memory_bytes: 6516
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

int n, a, b, c;
vector<int> l;

int solve(int crn, int A, int B, int C) {
    if (crn == n) {
        if (min({A, B, C}) <= 0) return INF;
        else return abs(a-A)+abs(b-B)+abs(c-C)-30;
    }
    int ret0 = solve(crn+1, A, B, C);
    int ret1 = solve(crn+1, A+l[crn], B, C)+10;
    int ret2 = solve(crn+1, A, B+l[crn], C)+10;
    int ret3 = solve(crn+1, A, B, C+l[crn])+10;
    return min(ret0, min(ret1, min(ret2, ret3)));
}

int main(int argc, char const *argv[]) {
    cin >> n >> a >> b >> c;
    l.resize(n);
    REP(i,n) cin >> l[i];
    cout << solve(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(5*1e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int from, to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/

int n, m, c;
int b[25];
int a[25][25];
signed main() {
	cin >> n >> m >> c;
	rep(i, m)cin >> b[i];
	int ans = 0;
	rep(i, n) {
		int sum = 0;
		rep(j, m) {
			cin >> a[i][j];
			sum += a[i][j] * b[j];
		}
		sum += c;
		if (sum > 0)ans++;
	}
	cout << ans << endl;
	endre;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007
 
#define SZ 1005
using namespace std;
ll b[SZ], t[SZ], p[SZ], tota[SZ];
int n,m;
ll fn(int x, int y, int z)
{
    for(int i=0; i<n; i++) tota[i] = b[i]*x + p[i]*y + t[i]*z;
    nth_element(tota, tota+m-1, tota+n, greater<ll>());
    ll sm = 0;
    for(int i=0; i<m; i++) sm += tota[i];
    return sm;
}
int main()
{
    cin>>n>>m;
    for(int i=0; i<n; i++)
        cin>>b[i]>>t[i]>>p[i];
    if(m == 0)
    {
        cout<<0<<endl;
        return 0;
    }
    ll ans = -1;
    ans = max(ans, fn(-1, -1, -1));
    ans = max(ans, fn(-1, -1, 1));
    ans = max(ans, fn(-1, 1, -1));
    ans = max(ans, fn(-1, 1, 1));
    ans = max(ans, fn(1, -1, -1));
    ans = max(ans, fn(1, -1, 1));
    ans = max(ans, fn(1, 1, -1));
    ans = max(ans, fn(1, 1, 1));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  bool ans=false;
  if(s=="keyence"){
    cout<<"YES"<<endl;
    return 0;
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      string t=s;
      if(t.erase(j,i)=="keyence")ans=true;
    }
  }
  if(ans)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

int main() {
    int n;
    cin>>n;
    vector<long long>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    if(a[0]==0){
        cout<<0;
        return 0;
    }
    long long ans=1,inf=1000000000000000000;
    rep(i,n){
        if(a[i]>inf/ans){
            cout<<-1;
            return 0;
        }
        ans*=a[i];
        if(ans>inf){
            cout<<-1;
            return 0;
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3980
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
  i64 from, to, cost;
  edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
  edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

template<typename T>
struct CumulativeSum{
    // usage: CumulativeSum<i64> ps(a); // (a = vector<i64>) - construct particial sum array
    //        query(a, b) - return sum[a, b)
    vector<T> sum;
    CumulativeSum(vector<T> a){
        sum = vector<T>(a.size() + 1);
        sum[0] = 0;
        for(int i = 0; i < a.size(); ++i){
            sum[i + 1] = sum[i] + a[i];
        }
    }
    T query(T x, T y){
        return -sum[min(x, y)] + sum[max(x, y)];
    }
};

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

	i64 n, k;
	cin >> n >> k;
	vector<i64> h(n);
	for(i64 i = 0; i < n; ++i) cin >> h[i];
	sort(h.begin(), h.end());
	i64 ans = INF<i64>;
	for(i64 i = 0; i < n - k + 1; ++i){
		ans = min(ans, h[k + i - 1] - h[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
s = list(input())
ans = 0
for i in range(2**(3)):
    f = (s[0])
    for j in range(3):
        if i&(1<<j):
            f = f+"+"
        else:
            f = f+"-"
        f = f+s[j+1]
    if eval(f)==7:
        print(f+"=7")
        exit()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	string s ; cin >> s ;
	int n = s.size() ;
	string s1="0" , s2 ="1" ;
	for(int i = 0 ; i < n - 1 ; i++){
		if(s1[s1.size() - 1] == '1') s1 += '0' ;
		else s1 += '1' ;
		if(s2[s2.size() - 1] == '1') s2 += '0' ;
		else s2 += '1' ;
	}
	//cout << s1 << " " << s2 << endl ;
	int nb1 = 0 , nb2 = 0 ;
	for(int i = 0 ; i < n ; i++){
		nb1 += (s[i] != s1[i]) ;
		nb2 += (s[i] != s2[i]) ;
	}
	cout << min(nb1 , nb2) << endl; 
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

double dp[3030][3030];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 3030)REP(j, 3030) dp[i][j] = 0;
    dp[0][0] = 1.0;

    ll N;
    cin >> N;
    vector<double> p(N);
    REP(i, N) cin >> p[i];

    REP(i, N){
    	REP(j, N){
    		dp[i+1][j+1] += dp[i][j] * p[i];
    		dp[i+1][j] += dp[i][j] * (1.0-p[i]);
    	}
    }

    double res = 0;
    REP(j, 3030){
    	if(j>N-j) res += dp[N][j];
    }
    printf("%.10f\n", res);
    return 0;
}

Measured memory_bytes: 72064
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x,y,a,b,c,i;
  cin>>x>>y>>a>>b>>c;
  vector<int64_t> p(a),q(b),r(c),t(x+y);
  int64_t s=0;
  for(i=0;i<a;i++) cin>>p.at(i);
  for(i=0;i<b;i++) cin>>q.at(i);
  for(i=0;i<c;i++) cin>>r.at(i);
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  sort(r.begin(),r.end());
  for(i=0;i<x;i++) t.at(i)=p.at(a-1-i);
  for(i=0;i<y;i++) t.at(x+i)=q.at(b-1-i);
  sort(t.begin(),t.end());
  for(i=0;i<c;i++) {
    if (t.at(i)<r.at(c-1-i)) t.at(i)=r.at(c-1-i);
    else break;
  }
  for(i=0;i<x+y;i++) s+=t.at(i);
  cout<<s<<endl;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;cin>>s>>t;int k=INT_MIN;
  for(int i=0;i<=s.length()-t.length();i++)
  {
    int p=0;
    for(int j=0;j<t.length();j++)
    {
      if(s[j+i]==t[j])
         {p++;}
         }
         k=max(p,k);
         }
         cout<<t.length()-k;
         }



Measured memory_bytes: 3576
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();

		int g = 0;
		int p = 0;
		int win = 0;
		for (int i = 0; i < s.length; i++) {
			if (g == p) {
				// グーを出す -> パーを出されていたら負け
				if (s[i] == 'p') {
					win--;
				}
				g++;
			} else {
				if (s[i] == 'g') {
					// パーを出す -> 勝つ
					win++;
					p++;
				} else if (s[i] == 'p') {
					// グーを出す -> あいこ
					p++;
				} else {
					throw new RuntimeException("g, p 以外の入力はおかしい");
				}
			}
		}

		System.out.println(win);
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 9428
"use strict"
function main(arg) {
  const data = arg.trim().split("\n")  
  console.log(solve(data.slice(1)))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function solve(arr) {
  arr.sort((s1, s2) => s1.localeCompare(s2))
  return arr.join('')
}




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

int main() {
  int N,ans,A=0,B=0,i;
  cin>>N;
  vector<int> card(N);
  
  for(i=0;i<N;i++){
  	cin>>card.at(i);
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  
  for(i=0;i<N;i++){
  	if(i%2==0) A+=card.at(i);
    else if(i%2==1) B+=card.at(i);
  }
  
  ans=A-B;
  if(ans<0) ans*=-1;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,X,Y;
    cin >> N >> X >> Y;
    int dp[N+1][N+1];
    int ans[N+1];
    for (int i=0;i<N+1;i++)
    {
        ans[i]=0;
        for (int j=0;j<N+1;j++)
        {
            dp[i][j]=INT_MAX/2;
        }
    }

    
    for (int i=1;i<N;i++)
    {
        dp[i][i+1]=1;
        dp[i+1][i]=1;
    }
    for (int i=1;i<N+1;i++)
    {
        dp[i][i]=0;
        if (i<X) 
        {
            dp[i][X]=X-i;
            dp[X][i]=X-i;
        }
        if (Y<i) 
        {
            dp[i][Y]=i-Y;
            dp[Y][i]=i-Y;
        }
        if ((X<i) &(i<Y))
        {
            if (i-X<Y-i) 
            {
                dp[i][X]=i-X;
                dp[X][i]=i-X;
            }
            else
            {
                dp[i][Y]=Y-i;
                dp[Y][i]=Y-i;
            }
             
        }
    }
    dp[X][Y]=1;
    dp[Y][X]=1;
    for(int i=1;i<N+1;i++)
    {
        for (int j=1;j<N+1;j++)
        {
            if (dp[i][j]>=INT_MAX/2)
            {
                dp[i][j]=min({dp[i][j-1]+1,dp[i][X]+dp[Y][j]+1,dp[i-1][j]+1,dp[j][i]});
            }
        }
    }
    for (int i=1;i<N+1;i++)
    {
        for (int j=1;j<N+1;j++)
        {
            ans[dp[i][j]]++;
        }
    }
    for (int i=1;i<N;i++) cout << ans[i]/2 << endl;
return 0;
}

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

int main() {
  int N, T, A, H, mi;
  cin >> N >> T >> A;
  double m=10000000;
  for (int i=0; i<N; i++) {
    cin >> H;
    double d=T-H*0.006;
    if (abs(d-A)<m) {
      m=abs(d-A);
      mi=i+1;
    }
  }
  cout << mi << endl;
}



Measured memory_bytes: 3596