akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
            string s;
            cin>>s;
            string tmp=s;
            reverse(all(tmp));
            string le=s.substr(0,(_sz(s)-1)/2);
            string ri=s.substr((_sz(s)-1)/2+1);
            string le1=le;
            reverse(all(le1));
            string ri1=ri;
            reverse(all(ri1));
            if(ri==ri1&&le==le1&&s==tmp){
                cout<<"Yes"<<nl;
            }
            else cout<<"No"<<nl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
vector<int> c;
vector<vector<pair<int, int>>> G;
void dfs(int v) {
	for (auto nx : G[v]) {
		if (c[nx.first] == -1) {
			if(nx.second % 2 == 0)c[nx.first] = c[v];
			else c[nx.first] = !c[v];
			dfs(nx.first);
		}
	}
}
int main()
{
	int n, u, v, w;
	cin >> n;
	G.resize(n);
	c.resize(n, -1);
	rep(i, 0, n - 1) {
		cin >> u >> v >> w;
		u--, v--;
		G[u].push_back({ v, w });
		G[v].push_back({ u, w });
	}
	c[0] = 1;
	dfs(0);
	for (auto ans : c) {
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 11084
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int A, B, K, i, n = 0;
  cin >> A >> B >> K;
  for (i = min(min(A, B), 100); i >= 1; i--) {
    if (A % i == 0 && B % i == 0) n++;
    if (n == K) break;
  }
  cout << i << endl;
}


Measured memory_bytes: 3196
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] w = sc.next().toCharArray();
    int[] t = new int[26];

    for (int i = 0; i < w.length; ++i) {
      ++t[w[i] - 97];
    }
    for (int i = 0; i < 26; ++i) {
      if (t[i] % 2 != 0) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}


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

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(ll i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()

#define sqr(a) ((a) * (a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define mem(a,b) memset(a,b,sizeof(a))

#define yes cout<<"YES"<<nl;
#define no cout<<"NO"<<nl;

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
   su;
   int a;
   cin>>a;
   cout<<a+sqr(a)+sqr(a)*a<<nl;
   return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	cout<<((k%2)?b-a:a-b)<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= b){
      for(int i=0; i<a; i++)
          cout << b;
    }else{
      for(int i=0; i<b; i++)
          cout << a;
    }
    return 0;
}


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

int main(){
    long long n;
    cin >>n;
    long long count=0;
    long long val;
    long long min=n;
    for(int i=0; i<n; i++){
        cin >> val;
        if(val <= min){
            count += 1;
            min = val;
        }
    }

    cout << count << endl;
    return 0;


}


Measured memory_bytes: 3640
//==========================================================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               100010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                             (int)1e9
#define        eps                             1e-9
#define        debug(x)                        cerr << #x << " is " << x << endl;
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%I64d",&aaa);return aaa;}
inline double dxt(){double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
///******************************************START******************************************

int main()
{
   int n=nxt();
   ll c=1;
   while(true){
        if((c*(c+1))/2>=n) break;
        c++;
     }
   printf("%lld\n",c);
    return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …
  	var N = parseInt(input);
	var ret = 'No';
  	var division7 = N/7;
  	var division4 = N/4;

	loop:
  	for(var i=0;i<=division7;i++){
      for(var j=0;j<=division4;j++){
        if(i*7 + j*4 === N){
          ret = 'Yes';
          break loop;
        }
      }
    }
  
	console.log(ret);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9
int main() {
    int a;
    cin >> a;
    vector<string> s(a);
    REP(i, a) cin >> s[i];
    vector<int> c(4);
    REP(i, a) {
        if (s[i] == "AC")
            c[0]++;
        else if (s[i] == "WA")
            c[1]++;
        else if (s[i] == "TLE")
            c[2]++;
        else if (s[i] == "RE")
            c[3]++;
    }
    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;
    return 0;
}

Measured memory_bytes: 6372
class Rest:

    def __init__(self, idx, city, point):
        self.idx = idx
        self.city = city
        self.point = point

    def __repr__(self):
        return repr((self.idx, self.city, self.point))

    def __lt__(self, other):
        if self.city == other.city:
            return self.point > other.point
        else:
            return self.city < other.city


N = int(input())
Rests = []

for i in range(0, N):
    S, P = input().split()
    Rests.append(Rest(i + 1, S, int(P)))

Rests.sort()

for i in Rests:
    print(i.idx)


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

int main()
{
  int n;
  cin >> n;
  int a[n],dp[n];
  
  for(int i=0; i<n; i++)
  {
   	cin >> a[i]; 
  }
  dp[0] = 0;
  dp[1] = abs(a[0]-a[1]);
  for(int i=2; i<n; i++)
  {
    dp[i] = min((dp[i-2]+abs(a[i]-a[i-2])),(dp[i-1]+abs(a[i]-a[i-1])));
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

int main(void)
{
    string str;
    cin >> str;
    if (str == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (str == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else if (str == "Rainy")
    {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
X, Y, A, B, C = map(int,input().split())
listp = list(map(int, input().split()))
listq = list(map(int, input().split()))
listr = list(map(int, input().split()))

listp = sorted(listp, reverse=True)
listq = sorted(listq, reverse=True)
listr = sorted(listr, reverse=True)
listp = listp[:X]
listq = listq[:Y]
listr = listr[:X+Y]
listp.insert(0, 1000000000000)
listq.insert(0, 1000000000000)


eat_noapple = []
oisisa = 0

for noapple in listr:
    if listp[-1] >= listq[-1] and listq[-1] < noapple:
        listq.pop(-1)
        eat_noapple.append(noapple)
    elif listp[-1] < listq[-1] and listp[-1] < noapple:
        listp.pop(-1)
        eat_noapple.append(noapple)
    else:
        break
listp.pop(0)
listq.pop(0)

try:
    for papple in listq:
        oisisa += papple
except:
    a = 0
try:
    for qapple in listp:
        oisisa += qapple
except:
    a = 0
try:
    for rapple in eat_noapple:
        oisisa += rapple
except:
    a = 0
print(oisisa)

Measured memory_bytes: 109392
def f(l,x):
  z=[]
  for i in range(x):
    if set(l[i])!=set('.'):
      z.append(l[i])
  return list(map(list, zip(*z)))
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
l=f(f(a,h),w)
for i in range(len(l)):
  print(''.join(l[i]))

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

typedef long long int ll;
const int maxn = 1e5 + 10;
void solved(){
	ll x;cin>>x;
	ll now = 100;
	int cnt = 0;
	while(now < x){
		now = now + 0.01 * now;
		cnt++;
	}
	cout<<cnt<<endl;
}
int main(){
	solved();
	return 0;
} 

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

int main(){
  double r1, r2;
  cin >> r1 >> r2;
  printf("%.9lf\n",(r1*r2)/(r1+r2));
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#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 el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int n; cin >> n; vector<string> s(n);
    for (int i=0;i<n;i++)
    {
        cin >> s[i];
    }
    map<string,ll> mp;
    for (int i=0;i<n;i++)
    {
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;
    }
    ll ans=0;
    for (map<string,ll> ::iterator it=mp.begin();it!=mp.end();it++)
    {
        ans+=((it->second-1)*(it->second))/2;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 16640
import fractions as f
a,b,c,d = map(int,input().split())
i = abs((a-1)//c-b//c)
j = abs((a-1)//d-b//d)
 
def lcm(x,y):
  return (x*y)//f.gcd(x,y)
l = lcm(c,d)
k = abs((a-1)//l-b//l)
print(b-a+1-(i+j-k))

Measured memory_bytes: 5052
//#pragma GCC optimize("Ofast")
	//#pragma GCC target("avx,avx2,fma")
	//#pragma GCC optimization ("unroll-loops")
	
    #include<bits/stdc++.h>
    using namespace std;
	
    #define ll long long
    #define ull unsigned long long
    #define ld long double
    #define ff first
    #define ss second
    #define null NULL
    #define MAX 1000000000  // 1x10^9
    #define all(c) (c).begin(),(c).end()
    #define eb emplace_back
    #define pb push_back
    #define pf push_front
    #define lb lower_bound   //used for sortted 
    #define ub upper_bound 
    #define m_p make_pair      
    #define mod 1000000007
    #define For(i,n) for(int i=(0);i<(n);++i)
    #define FOR(i,a,b) for(int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
    #define in(s3) inserter((s3), (s3).begin())  //	set_union(all(s1),all(s2),in(s3));
    typedef vector<ll> vl;
    typedef vector< vl > vvl;
    typedef pair< ll,ll> pll;
    typedef map< ll,ll> mll;
    
    //  A-65 Z-90 a-97 z-122   A-a = 32   Z-A = z-a = 35
    //	v.push_back(make_pair(min(2 * k[i], l[i]) - min(k[i], l[i]), i));      //int pos = v[i].second;
    //	floor(log10(no) + 1);                   //	to_string(no).length();             ----- length of a number
	//  llabs - long long of abs
	//  labs -long of abs
	//  sqrtf - sq root of float
	//  sqrtl - sq of long double    ( cout << fixed << setprecision(12) << sqrtl(val2) << endl; )
	//  it = find (all(vec), e);     if(it != vec.end());       it - vec.begin();
   	//	size_t found = str.find(str1);    if(found != string::npos); 	 cout<<found;
    	 
	/*	
		1. ^ is XOR and is used to to check odd occurance of number as a number XORed with itself results in zero so all even	occurrances result in zero.
		2.   & is used to check even or odd. (x & 1) ? printf("Odd") : printf("Even"); 
		3.   left shift(<<) - *         right shift(>>) - /
		4.   int a[] = { 1, 7, 2, 4, 8, 3 }; 
    		 int l = sizeof(a) / sizeof(a[0]); 
    		 sort(a, a + l);  reverse(a, a + l); accumulate(a, a + l, 0); *max_element(a, a + l);
	*/
	
	string to_string(char& x) {      
		string s(1,x);
		return s;    
	} 
	struct obj {
		ull val1;
		ull val2;
		ull pos;
	};
	bool cmp(const pair<int,int>&a,const pair<int,int>&b) {
		if(a.first==b.first)
		return a.second<b.second;
		return a.first<b.first;
	}

	int main() {
		string s,t;
		cin>>s>>t;
		int index=0,max=0,count,k;
		for(int i=0;i<s.length()-t.length()+1;i++)
		{
			count=0,k=0;
			for(int j=i;j<i+t.length();j++)
			{
				//cout<<s[j]<<endl;
				if(t[k]==s[j])
				{
				count++;
				}
				k++;
			}
			if(count>max)
			{
			max=count;
			}
		}
		//cout<<max<<endl;
		cout<<t.length()-max;
		return 0;
	}





Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int mi = 200;
    for (char i = 'a'; i <= 'z'; i++) {
      int m = 0;
      String[] ws = s.split("" + i);
      for (String w : ws) {
        m = Math.max(m, w.length());
      }
      mi = Math.min(m, mi);
    }
    System.out.println(mi);
  }
}

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

dp = list(range(N+1))

for amount in range(6, N+1):
    unit = 6
    while unit <= amount:
        dp[amount] = min(dp[amount], dp[amount-unit]+1)
        unit *= 6

    unit = 9
    while unit <= amount:
        dp[amount] = min(dp[amount], dp[amount-unit]+1)
        unit *= 9

print(dp[N])

Measured memory_bytes: 6900
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < n; i++)
    #define repr(i, n) for (int i = n-1; i >= 0; i--)
    #define ALL(x) x.begin(), x.end()
    using ll = long long;
    using pii = pair<int, int>;
    using vi = vector<int>;
    const int mod = 1e9+7;
    const int INF = 1e9;
    const int MAX = 1e6;
     
    ll solve(ll n, ll m) {
        ll r = (n-2) * (m-2);
        if (r < 0) r *= -1;
        return r;
    }
     
    int main() {
        ll n, m;
        cin >> n >> m;
        cout << solve(n, m) << endl;
    }

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <pair <int, int>> vii;

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    int n, k, q;
    cin >> n >> k >> q;
    vi v(n);
    re(q) {
        int x;
        cin >> x;
        ++v[x - 1];
    }
    re(n) {
        int res = k;
        res -= q - v[i];
        // cout << res << endl;
        if (res <= 0) cout << "No\n";
        else cout << "Yes\n";
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

vector<int> G[200005];

signed main(){
  int n,m,q;
  cin>>n>>m>>q;
  
  for(int i=0; i<m; i++){
    int l,r;
    cin>>l>>r;
    G[l].push_back(r);
  }
  for(int i=1; i<=n; i++) sort(G[i].begin(), G[i].end());
  for(int i=0; i<q; i++){
    int l,r;
    cin>>l>>r;
    int ans=0;
    for(int j=l; j<=r; j++){
      int n=upper_bound(G[j].begin(), G[j].end(), r)-G[j].begin();
      ans+=n;
    }
    cout<<ans<<en;
  }
}


Measured memory_bytes: 8064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 410;
const ll MOD = 1e9 + 7;

int n, c;
ll dp[MAXN];
ll dp2[MAXN];
ll pw[MAXN][MAXN];
int l[MAXN];
int r[MAXN];

int main() {
	for (int i = 1; i < MAXN; ++i) {
		pw[i][0] = 1;
		for (int j = 1; j < MAXN; ++j)
			pw[i][j] = (pw[i][j - 1] * i) % MOD;
	}
	cin >> n >> c;
	for (int i = 0; i < n; ++i)
		cin >> l[i];
	for (int i = 0; i < n; ++i)
		cin >> r[i];
	dp[0] = 1;
	for (int i = 0; i < n; ++i) {
		memset(dp2, 0, sizeof(dp2));
		for (int j = 0; j <= c; ++j) {
			ll go = 0;
			for (int k = l[i]; k <= r[i]; ++k) {
				go += pw[k][j];
				if (go >= MOD)
					go -= MOD;
			}
			for (int k = 0; k <= c - j; ++k)
				dp2[k + j] = (dp2[k + j] + go * dp[k]) % MOD;
		}
		memcpy(dp, dp2, sizeof(dp2));
	}
	cout << dp[c] << "\n";
	return 0;
}




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

// ---- ----

int f(int n) { return n * (n + 1) / 2; }

int main() {
	int k, s;
	scanf("%d%d", &k, &s);
	
	if(s >= 2 * k) { s = 3 * k - s; }
	
	int ans = f(s + 1);
	if(s > k) { ans -= 3 * f(s - k); }
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 200000
using namespace std;
typedef long long lnt;
int n, m; lnt tot;
char s[MAX_N+5];
int main() {
	scanf("%s", s+1);
	n = (int)strlen(s+1);
	for (int i = 1; i <= n; i++)
		if (s[i] == 'B') m++;
		else tot += m;
	return printf("%lld\n", tot), 0;
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  n %= 10;
  if (n == 3) {
    cout << "bon\n";
    return 0;
  }
  if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon\n";
  } else {
    cout << "hon\n";
  }
  return 0;
}


Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    L=list(mi())

    ans = 0
    for i in range(N):
        for j in range(i,N):
            if i == j: continue
            for k in range(j,N):
                if j == k: continue
                a,b,c = L[i],L[j],L[k]
                if a != b  and b != c and c != a:
                    if a+b>c and  b+c>a and  c+a>b:
                        ans += 1

    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 68064
n = int(input())
H = [0]+list(map(int, input().split()))+[0]
ans = 0
while max(H)>0:
    Zero = []
    for i in range(n+2):
        if H[i] == 0:
            Zero.append(i)

    for i in range(len(Zero)-1):
        if Zero[i+1] == Zero[i] + 1:
            continue
        grw = min( H[Zero[i]+1:Zero[i+1]] )
        for j in range( Zero[i]+1, Zero[i+1] ):
            H[j] -= grw
        ans += grw
print(ans)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string g(string s,string t){
	int n=s.size(),m=t.size();
	if(s=="invalid") return t;
	if(t=="invalid") return s;
	if(n>m) return s;
	if(n<m) return t;
	for(int i=0;i<n;i++){
		if(s[i]<t[i]) return t;
		if(s[i]>t[i]) return s;
	}
	return s;
}

int n;
string s;
vector<vs> dp;

string f(int l,int r){
	if(dp[l][r]!="") return dp[l][r];
	bool B=1;
	for(int i=l;i<=r;i++) if(!isdigit(s[i])&&s[i]!='?') B=0;
	if(B){
		if(s[l]=='0'&&l<r) return dp[l][r]="invalid";
		string t;
		for(int i=l;i<=r;i++){
			if(s[i]=='?') t+='9';
			else t+=s[i];
		}
		return dp[l][r]=t;
	}
	if(r-l+1<=5) return dp[l][r]="invalid";
	if(isdigit(s[l])||s[l]==','||s[l]=='('||s[l]==')') return dp[l][r]="invalid";
	if(isdigit(s[l+1])||isalpha(s[l+1])||s[l+1]==','||s[l+1]==')') return dp[l][r]="invalid";
	if(isdigit(s[r])||isalpha(s[r])||s[r]==','||s[r]=='(') return dp[l][r]="invalid";
	dp[l][r]="invalid";
	if(s[l]=='L'||s[l]=='?'){
		for(int i=l+2;i<r-2;i++) if(s[i+1]=='?'||s[i+1]==','){
			auto lt=f(l+2,i),rt=f(i+2,r-1);
			if(lt!="invalid"&&rt!="invalid"){
				dp[l][r]=g(dp[l][r],lt);
			}
		}
	}
	if(s[l]=='R'||s[l]=='?'){
		for(int i=l+2;i<r-2;i++) if(s[i+1]=='?'||s[i+1]==','){
			auto lt=f(l+2,i),rt=f(i+2,r-1);
			if(lt!="invalid"&&rt!="invalid"){
				dp[l][r]=g(dp[l][r],rt);
			}
		}
	}
	return dp[l][r];
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>s;
	n=s.size();
	dp=vector<vs>(n,vs(n,""));
	cout<<f(0,n-1)<<endl;
}


Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#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("%.10f\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(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(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=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int x,a,b;
  cin >> x >> a >> b;
  if(b<=a) pr("delicious");
  else if(b<=a+x) pr("safe");
  else pr("dangerous");
}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    
    return 0;
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define fi first 
#define se second 
#define mod 1000000007
/* Iterative Function to calculate (x^y) in O(log y) */
ll power(ll x, ll y) 
{ 
	int res = 1;	 // Initialize result 

	while (y > 0) 
	{ 
		// If y is odd, multiply x with result 
		if (y & 1) 
			res = res*x; 

		// y must be even now 
		y = y>>1; // y = y/2 
		x = x*x; // Change x to x^2 
	} 
	return res; 
}

int power(ll x, ll  y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
// vector<vector<ll>> v ;
// vector<ll> chld,bol,lst ;
// void dfs(ll a)
// {
//   lst.pb(a) ;
//   for(ll i=0;i<v[a].size();i++)
//   {
//     if(bol[v[a][i]]==0)
//     {
//       bol[v[a][i]]=1 ;
//       dfs(v[a][i]) ;
//     }
//   }
// }
// ll ch(ll a)
// {
//   ll p=0;
//   if(v[a].size()==0)
//   {
//     chld[a] =1 ;
//    return 1;
//   }
//   else
//   {
//     for(ll i=0;i<v[a].size();i++)
//     p += ch(v[a][i]) ;
//     p++ ;
//     chld[a] = p;
//     return p;
//   }
// }
int count(char x,string s)
{
  if(s.size()==1&&s[0]==x) return 0;
  else if(s.size()==1) return 1;
  else
  {
    ll a=0,b=0 ;
    for(ll i=0;i<s.size()/2;i++) if(s[i]==x) a++ ;
    for(ll i=s.size()/2;i<s.size();i++) if(s[i]==x) b++ ;
    return min(s.size()/2 - a + count(x+1,s.substr(s.size()/2,s.size()/2)),s.size()/2 - b + count(x+1,s.substr(0,s.size()/2))) ;
    
  }
}
int main()
{
  int n;
  cin >> n ;
  int a=0,b=0,c=0,d=0 ;
  while(n--)
  {
    string s;
    cin >> s;
    if(s=="AC") a++ ;
    else if(s=="TLE") c++ ;
    else if(s=="WA") b++ ;
    else d++ ;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        if (n % 2 == 1) {
            for (int i = 1; i <= m; i++) {
                System.out.println(i + " " + (n - i + 1));
            }
            return;
        }

        boolean flag = false;
        for (int i = 1; i <= m; i++) {
            if (n - 2 * i + 1 <= n / 2) {
                flag = true;
            }
            if (flag) {
                System.out.println(i + " " + (n - i));
            } else {
                System.out.println(i + " " + (n - i + 1));
            }
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


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

namespace GuessTheNumber
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            int[] array = Array.ConvertAll(inputs, x => int.Parse(x));

            if(array[0] == array[1] && array[1] == array[2])
            {
                Console.WriteLine("No");
            }
            else if(array[0] == array[1] || array[0] == array[2] || array[1] == array[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7;
int n,m,p,sr,sc;
char s[N],t[N];
bool walk1()
{
    int L=1,R=n;
    for(int i=p;i;i--)
    {
        if(t[i]=='U')R=min(n,R+1);else if(t[i]=='D')L=max(1,L-1);
        if(s[i]=='U')L++;else if(s[i]=='D')R--;
        if(L>R)return 1;
    }
    return (sr<L||sr>R);
}
bool walk2()
{
    int L=1,R=m;
    for(int i=p;i;i--)
    {
        if(t[i]=='L')R=min(m,R+1);else if(t[i]=='R')L=max(1,L-1);
        if(s[i]=='L')L++;else if(s[i]=='R')R--;
        if(L>R)return 1;
    }
    return (sc<L||sc>R);
}
int main()
{
    scanf("%d%d%d%d%d",&n,&m,&p,&sr,&sc);
    scanf("%s",s+1);
    scanf("%s",t+1);
    if(walk1()||walk2())puts("NO");
    else puts("YES");
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<string> v(n);
  REP(i, n)cin >> v[i];
  vector<vector<int>> dp(n, vector<int>(m,INF));
  dp[0][0] = v[0][0] == '#';
  REP(i, n)REP(j, m) {
    if (i) {
      if (v[i][j] != v[i - 1][j] && v[i][j] == '#')chmin(dp[i][j], dp[i - 1][j] + 1);
      else chmin(dp[i][j], dp[i - 1][j]);
    }
    if (j) {
      if (v[i][j] != v[i][j - 1] && v[i][j] == '#')chmin(dp[i][j], dp[i][j - 1] + 1);
      else chmin(dp[i][j], dp[i][j - 1]);
    }
  }
  cout << dp[n - 1][m - 1] << endl;

}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<unordered_map>
#include<random>
#include<fstream>
#include<iterator>
#include <numeric>

using namespace std;

int main() {

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

	int a, b, k;

	cin >> a >> b >> k;

	if (b - a < k * 2) {
		for (int i = a; i <= b; i++) {
			cout << i << endl;
		}
	}

	else {
		for (int i = a; i < a + k; i++) {
			cout << i << endl;
		}

		for (int i = b - k + 1; i <= b; i++) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES  // M_PI等のフラグ

#include <iostream>
#include <bitset>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <list>

#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

using namespace std;


void solve(){
    int D, T, S;
    cin >> D >> T >> S;
    if ((double)D/S > T) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	int n,t;
	while(cin >> n && n){
		int a[n];
		int r=0;
		for(int i=0;i<n;i++){
			cin >> a[i];
		}
		for(int i=n-1;i>0;i--){
			for(int j=1;j<=i;j++){
				if(a[j-1]>a[j]){
					swap(a[j-1],a[j]);
					r++;
				}
			}
		}
		cout << r << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
  int x,y,a;

  scanf("%d %d",&x,&y);

  while (x!=0 || y!=0) {
    if (x > y) {
      a = x;x = y;y = a;
    }
    printf("%d %d\n",x,y);
    scanf("%d %d",&x,&y);
  }
  return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b, c; cin >> a >> b >> c;
  a -= c;
  fin(a / (b + c))
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>

#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 1000000;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> P;
typedef long long ll;


void zerofill(int *inp, int size){
    for(auto i= 0; i< size; i++){
        inp[i] = 0;
    }
}

int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int getDigit(int num){
    return log10(abs(num))+1;
}


long long fac[MAX];
long long finv[MAX];
long long inv[MAX];

void binom_init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; ////  inv[i] = div(1,i) =  (1/i) mod M;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long binom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int mypush(queue<int> &candidate,int inp, int N){
    
    if (inp <= pow(10,getDigit(N)-1)){
        candidate.push(inp);
    }

    return (inp <= N);
    
}


int consistent(int inp,int N){
    
    string s = to_string(inp);
    
    sort(s.begin(),s.end());
    s.erase(unique(s.begin(),s.end()),s.end());
    
    if (s[0] != '3') return 0;
    if (s[1] != '5') return 0;
    if (s[2] != '7') return 0;
    
    return (inp <= N);
    
}

int main() {
    
    int N = in();
    int K = in();
    
    vector<int> trees;
    
    for(auto i = 0; i<N; i++){
        trees.push_back(in());
    }
    
    
    sort(trees.begin(),trees.end());
    
    int min = INT_MAX;
    for(auto k = 0; k+K-1 < N; k++){
        
        if (min > trees[k+K-1]-trees[k]){
            min = trees[k+K-1]-trees[k];
        }
        
    }
    
    cout << min << endl;
    
    
    return 0;
}






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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

ll a[3001][3001];
ll dp[3001][3001][3];

int main(){
	IOS;
	int r,c,i,j,k,ri,ci,v;
	cin>>r>>c>>k;
	REP(i,1,k){
		cin>>ri>>ci>>v;
		a[ri][ci]=v;
	}
	REP(i,1,r){
		REP(j,1,c){
			dp[i][j][0]=max(dp[i-1][j][2]+a[i][j],dp[i][j-1][0]);
			dp[i][j][1]=max(dp[i][j-1][0]+a[i][j],dp[i][j-1][1]);
			dp[i][j][2]=max({dp[i][j-1][1]+a[i][j],dp[i][j][0],dp[i][j][1],dp[i][j-1][2]});
		}
	}
	cout<<dp[r][c][2];
	return 0;
}

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


def main():
    from collections import Counter

    n = int(input())
    d = list(map(int, input().split()))
    c = Counter(d)

    # KeyInsight
    # 条件を満たす個数：距離Diの頂点に対して親の個数の数だけ辺が張れるか，と言い換え

    # 気がつけた点
    # D1は0，それ以外は1l以上であるかどうかで場合分け
    # サンプルから組み合わせを愚直に数えた

    # 気がつけなかった点
    # 各距離における組み合わせを効率的に求める方法．重複組み合わせを数えようとしていた
    if d[0] == 1 or (0 in d[1:]):
        print(0)
        exit()

    ans = 1
    mod = 998244353

    for i in c.keys():
        if i >= 1:
            ans *= c[i - 1] ** c[i]
            ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19936
# coding: utf-8
# Your code here!

from collections import defaultdict

N = int(input())
X = list(map(int, input().rstrip().split(' ')))
X = sorted(X)

count_minus = sum([1 if x < 0 else 0 for x in X])

if N == 2:
    print(X[1] - X[0])
    print(X[1], X[0])
else:
    ope = []
    min_value = X[0]
    max_value = X[-1]
    start = 1
    end = N-1

    for i in range(start, end):
        if X[i] < 0:
            ope.append([max_value, X[i]])
            max_value -= X[i]
        else:
            ope.append([min_value, X[i]])
            min_value -= X[i]
    ope.append([max_value, min_value])
    
    print(max_value - min_value)
    for i in range(len(ope)):
        a, b = ope[i]
        print(a, b)

Measured memory_bytes: 70364
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, ans;
	cin >> a >> b;
	if (b < a) ans = a - 1;
	else ans = a;

	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        x:usize,
    }
    let grade = if x < 600 {
        8
    } else if x < 800 {
        7
    } else if x < 1000 {
        6
    } else if x < 1200 {
        5
    } else if x < 1400 {
        4
    } else if x < 1600 {
        3
    } else if x < 1800 {
        2
    } else if x < 2000 {
        1
    } else {
        panic!("invalid grade");
    };
    grade.to_string()
}
test! {}


Measured memory_bytes: 2100