akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int h, w;
    scanf("%d%d", &h, &w);
    vector<vector<char>> a(h, vector<char>(w));
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> a.at(i).at(j);
        }
    }
    vector<bool> row(h, false);
    vector<bool> col(w, false);
    rep(i, h)
    {
        rep(j, w)
        {
            if (a.at(i).at(j) == '#')
            {
                row[i] = true;
                col[j] = true;
            }
        }
    }
    rep(i, h)
    {
        if (row[i])
        {
            rep(j, w)
            {
                if (col[j])
                {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;

const int MOD = 1000000007;

struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};

mint operator-(mint a) {
  return -a.n + MOD * (a.n != 0);
}
mint operator+(mint a, mint b) {
  int x = a.n + b.n;
  return x - (x >= MOD) * MOD;
}
mint operator-(mint a, mint b) {
  int x = a.n - b.n;
  return x + (x < 0) * MOD;
}
mint operator*(mint a, mint b) {
  return (long long)a.n * b.n % MOD;
}
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

mint dp[100005];

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<bool> bad(n + 1);
  REP(i, m) {
    int x; cin >> x;
    bad[x] = true;
  }
  dp[0] = 1;
  REP(i, n) {
    if (!bad[i + 1]) dp[i + 1] += dp[i];
    if (!bad[i + 2]) dp[i + 2] += dp[i];
  }
  cout << dp[n] << endl;
}





Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int w,h,n;
  cin>>w>>h>>n;
  vector<int> v1(1,0),v2(1,w),v3(1,0),v4(1,h);
  REP(i,n){
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1) v1.emplace_back(x);
    else if(a==2) v2.emplace_back(x);
    else if(a==3) v3.emplace_back(y);
    else if(a==4) v4.emplace_back(y);
  }
  sort(ALL(v1),greater<int>());
  sort(ALL(v2));
  sort(ALL(v3),greater<int>());
  sort(ALL(v4));
  int x=(v2[0]-v1[0]>0)? v2[0]-v1[0]:0,y=(v4[0]-v3[0]>0)? v4[0]-v3[0]:0;
  cout<<x*y<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	s[k - 1] -= ('A' - 'a');
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N; cin >> N;
	V<int> s,t;
	REP(i, N) {
		int a; 
		cin >> a;
		if (a % 10 == 0) s.push_back(a);
		else t.push_back(a);
	}

	sort(ALL(t));
	int sum = 0;
	REP(i, s.size()) sum += s[i];
	REP(i, t.size()) sum += t[i];

	if(t.size() == 0){
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; i < t.size() && (sum % 10 == 0); ++i) sum -= t[i];
	cout << sum << endl;
	

	return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll N;
vector<ll> a;
vector<ll> b;
ll ans;

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

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

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

	sort(a.begin(),a.end()); sort(b.begin(),b.end());

	ll t= 1;
	for (int k = 0;k < 40;k++){

		vector<ll> c(N), d(N);
		for (int i = 0;i < N;i++){
			c[i] = a[i]%(2*t);
			d[i] = b[i]%(2*t);
		}

		sort(c.begin(),c.end()); sort(d.begin(),d.end());

		ll cnt = 0;
	
		for (int j = 0;j < N;j++){
			cnt += lower_bound(d.begin(),d.end(),2*t-c[j]) - lower_bound(d.begin(),d.end(),t-c[j])
							+ d.end() - lower_bound(d.begin(),d.end(),3*t-c[j]);
		}

		if(cnt%2 == 1){
			ans +=  t;
		}

		t *= 2;

	}

	cout << ans << endl;

	return 0;

}


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

inline void fastRead_int(int &x) {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;

    for(; ((c<48 || c>57) && c != '-'); c = getchar_unlocked());

    if(c=='-') {
      neg = 1;
      c = getchar_unlocked();
    }

    for(; c>47 && c<58 ; c = getchar_unlocked()) {
      x = (x<<1) + (x<<3) + c - 48;
    }

    if(neg)
      x = -x;
}

int main(){

	int n, W;
	fastRead_int(n); fastRead_int(W);

	int val[n], wt[n];
	for (int i = 0; i < n; ++i)	{
		fastRead_int(wt[i]);
		fastRead_int(val[i]);
	}

	long long int dp[W+1]; 
    
    memset(dp, 0ll, sizeof(dp)); 
  
    for(int i = 0; i < n; i++) {
        for(int j = W; j >= wt[i]; j--) {
            dp[j] = max(dp[j] , val[i] + dp[j-wt[i]]); 
        }
    }

	printf("%lld\n", dp[W]);

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll A, B, C;
  cin>>A>>B>>C;
  if(C-A-B>=0 && 4*A*B<(C-A-B)*(C-A-B)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



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

int main(){
	char A[10],B[10],C[10],i=0;
	cin >> A >> B >> C;
	while(A[i]!='\0') i++;
  	if(A[i-1]==B[0]){
      i=0;
      while(B[i]!='\0') i++;
      if(B[i-1]==C[0]) cout << "YES" << endl;
      else cout << "NO" << endl;
    }
  	else cout << "NO" << endl;
}


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

#define lint long long int

using namespace std;

int main()
{
	int n;
	cin >> n;
	int activity[n][3];
	for (int i = 0; i < n; i++)
	{
		cin >> activity[i][0];
		cin >> activity[i][1];
		cin >> activity[i][2];
	}
	int DP_table[n][3];
	DP_table[0][0] = activity[0][0];
	DP_table[0][1] = activity[0][1];
	DP_table[0][2] = activity[0][2];
	for (int i = 1; i < n; i++)
	{
		DP_table[i][0] = activity[i][0] + max(DP_table[i - 1][1], DP_table[i - 1][2]);
		DP_table[i][1] = activity[i][1] + max(DP_table[i - 1][0], DP_table[i - 1][2]);
		DP_table[i][2] = activity[i][2] + max(DP_table[i - 1][0], DP_table[i - 1][1]);
	}
	cout << max(DP_table[n - 1][0], max(DP_table[n - 1][1], DP_table[n - 1][2]));
}

Measured memory_bytes: 2560
#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>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll


signed main(){
  int n;
  while(cin>>n&&n){
    vector<P> G[15];
    
    int maxl=0;
    for(int i=0; i<n; i++){
      int a,b,c; cin>>a>>b>>c;
      G[a].push_back(mk(b,c));
      G[b].push_back(mk(a,c));
      maxl=max(maxl,max(a,b));
    }
    
    P min_ans; min_ans.first=INF;
    for(int i=0; i<=maxl; i++){
      int c[15];
      bool come[15];
      for(int j=0; j<=10; j++){c[j]=INF; come[j]=false;}
      
      priority_queue<P, vector<P>, greater<P> > que;
      que.push(mk(0,i));
      c[i]=0;
      int sum=0;
      while(!que.empty()){
        int at=que.top().second; int how_much=que.top().first;
        que.pop();
        if(come[at]) continue;
        sum+=how_much;
        come[at]=true;
        for(int j=0; j<G[at].size(); j++){
          int to=G[at][j].first;
          if(come[to]) continue;
          if(c[to]>how_much+G[at][j].second){
            c[to]=how_much+G[at][j].second;
            que.push(mk(c[to],to));
          }
        }
      }
    
      if(min_ans.first>sum){
        min_ans.first=sum; min_ans.second=i;
      }
    }
    
    cout<<min_ans.second<<" "<<min_ans.first<<en;
  }
}






Measured memory_bytes: 3112
#include<stdio.h>
int main(){
    int a,b;
	scanf("%d%d",&a,&b);
	if(a>b)
	{
	printf("a > b\n");
	}
	else if(a<b)
	{
	printf("a < b\n");
	}
	else if(a==b)
	{
	printf("a == b\n");
	}
}

Measured memory_bytes: 1008
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
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();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8

int main(){
	while(1){
		int e,x,y,z,ret=1000000;
		cin>>e;
		if(e==0)return 0;
		z=0;
		while(z*z*z<=e){
			int e2 = e-z*z*z;
			int i=0;
			while(1){
				if(i*i>e2){
					y=i-1;
					e2-=(i-1)*(i-1);
					break;
				}
				i++;
			}
			ret = min(ret,e2+y+z);
			z++;
		}
		cout << ret<<endl;
	}
}

Measured memory_bytes: 1160
import sys
from collections import defaultdict

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
a = na()

cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = (cum[i] + a[i] + k - 1) % k

dic = defaultdict(int)
ans = 0
for i in range(n+1):
    ans += dic[cum[i]]
    dic[cum[i]] += 1
    if i-(k-1) >= 0:
        dic[cum[i-(k-1)]] -= 1
print(ans)


Measured memory_bytes: 102860
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    set<int> tar;
    REP(i,n){
      int tmp;
      cin>>tmp;
      tar.insert(tmp);
    }
    vector<int> taro;
    vector<int> hanako;
    for(int i=1; i<=2*n; i++){
      if(tar.find(i)!=tar.end()){
        taro.push_back(i);
      }else{
        hanako.push_back(i);
      }
    }
    int ba=-1;
    vector<int>::iterator it1,it2;
    while(!taro.empty()&&!hanako.empty()){
      it1 = upper_bound(taro.begin(),taro.end(),ba);
      if(it1!=taro.end()){
        ba = (*it1);
        taro.erase(it1);
        if(taro.empty()) break;
      }else{
        ba = (*hanako.begin());
        hanako.erase(hanako.begin());
        continue;
      }

      it2 = upper_bound(hanako.begin(),hanako.end(),ba);
      if(it2!=hanako.end()){
        ba = (*it2);
        hanako.erase(it2);
      }else{
        ba = -1;
        continue;
      }
    }
    cout<<hanako.size()<<endl;
    cout<<taro.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
n=int(input())
p_list=[2]
for i in range(3,1000):
  for p in p_list:
    if i%p==0:
      break
  else:
    p_list.append(i)

p_kosu=[0,0]
for i in range(1,10):
  p_kosu[0]+=n//(2**i)
  p_kosu[1]+=n//(3**i)
for p in p_list:
  if p==2 or p==3:
    continue
  if p>n:
    break
  kosu=n//p
  if p**2>n:
    p_kosu.append(kosu)
    continue
  kosu+=n//(p**2)
  if p**3>n:
    p_kosu.append(kosu)
    continue
  kosu+=n//(p**3)
  if p**4>n:
    p_kosu.append(kosu)
    continue
  kosu+=n//(p**4)
  p_kosu.append(kosu)
ans=1
for i in p_kosu:
  ans=ans*(i+1)%1000000007
print(ans)

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

int main() {
	int N, i;
	string S;
	cin >> N >> S;
	int x[N+1] ;
	x[0] = 0;
	int max=0;
	for (i = 0; i < N; i++) {
		if (S[i] == 'I') { x[i+1]=x[i]+1; }
		else { x[i + 1] = x[i] - 1; }
	}
	for (i = 0; i < N + 1; i++) {
		if (x[i] > max) { max = x[i]; }
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  int sum=0;
  for(int div=1; n/div>0; div*=10){
    sum+=(n/div)%10;
  }
  assert(sum>0);
  if(n%sum==0) writeln("Yes");
  else writeln("No");
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) stderr.write(e, " ");
  stderr.writeln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
template<typename T> using Graph = vector<vector<T>>;

struct edge { int to, cap, cost, rev; };

int V;
const int MAX_V = 100;
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, int cost) {
    G[from].emplace_back((edge){to, cap, cost, (int)G[to].size()});
    G[to].emplace_back((edge){from, 0, -cost, (int)G[from].size() - 1});
}

int min_cost_flow(int s, int t, int f) {
    int res = 0;
    while (f > 0) {
        fill(dist, dist + V, inf);
        dist[s] = 0;
        bool update = true;
        while (update) {
            update = false;
            for (int v = 0; v < V; v++) {
                if (dist[v] == inf) continue;
                for (int i = 0; i < G[v].size(); i++) {
                    edge &e = G[v][i];
                    if (e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
                        dist[e.to] = dist[v] + e.cost;
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        update = true;
                    }
                }
            }
        }

        if (dist[t] == inf) {
            return -1;
        }

        int d = f;
        for (int v = t; v != s; v = prevv[v]) {
            d = min(d, G[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * dist[t];
        for (int v = t; v != s; v = prevv[v]) {
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

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

    int E, F;
    cin >> V >> E >> F;
    rep(i, E) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        add_edge(u, v, c, d);
    }
    cout << min_cost_flow(0, V - 1, F) << endl;
}

Measured memory_bytes: 3268
<?php
while (true) {
    fscanf(STDIN, "%d %d", $inputNumX, $inputNumY);
    if ($inputNumX === 0 && $inputNumY === 0) {
        break;
    }
    echo orderByAskForTwoNums($inputNumX, $inputNumY), PHP_EOL;
}

function orderByAskForTwoNums($inputNumX, $inputNumY)
{
    return min($inputNumX, $inputNumY).' '.max($inputNumX, $inputNumY);
}

Measured memory_bytes: 15176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

int main() {
  ll N;
  std::cin >> N;
  string S;
  std::cin >> S;
  std::vector<ll> W(N), E(N);
  REP(i, N) {
    if (S.at(i) == 'W') {
      W.at(i)++;
    } else {
      E.at(i)++;
    }
    if (i != N - 1) {
      W.at(i + 1) = W.at(i);
      E.at(i + 1) = E.at(i);
    }
  }
  ll min_ = N;
  REP(i, N) {
    ll count;
    if (i == 0) {
      count = E.at(N - 1);
    } else if (i == N - 1) {
      count = W.at(N - 2);
    } else {
      count = W.at(i - 1) + (E.at(N - 1) - E.at(i));
    }
    min_ = min(min_, count);
  }
  std::cout << min_ << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 5380
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin >> n;
    int a[100010];
    for(int i = 0; i < 100005; i++){
        a[i] = 0;
    }
    for(int i = 0; i < n; i++){
        int in;
        cin >> in;
        if(in <= 100000){
            a[in]++;
        }
    }
    int ans = n;
    for(int i = 1; i <= 100000; i++){
        if(a[i] >= i){
            ans -= i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int N, Y;
  cin >> N >> Y;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 0; i + j <= N; j++)
    {
      if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y)
      {
        cout << i << " " << j << " " << N - i - j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

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

long long b,p,m=1000000007,rt=1;

int main() {
	cin>>b>>p;
	for (;p;p>>=1,b=b*b%m) if (p&1) rt=rt*b%m;
	cout<<rt<<'\n';
}


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

int main(){
  int a,b;
  cin>>a>>b;

  if( a < b ) cout<<"a < b"<<endl;
  if( a > b ) cout<<"a > b"<<endl;
  if( a == b ) cout<<"a == b"<<endl;

  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
#define long long long

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef vector<int> vi;
typedef vector<pair<int, int>> vii;

const double PI = acos(-1.0), EPS = 1e-9;
const int MAXN = 100005, MAXM = 102, Mod = 998244353, MAXLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout
            << fixed;


    long n;
    cin >> n;
    long ans = LLONG_MAX;
    for (int i = 1; 1LL * i * i <= n; ++i) {
        if (n % i == 0) {
            ans = min(ans, i + n / i - 2);
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
template <class T>
map< T, int > prime_factor(T n) {
    map< T, int > ret;
    for(T i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

void Main(){
  int n;
  ll x;
  cin>>n>>x;
  ll pre = 0;
  ll ans = 0;
  rep(i,n){
    ll t;
    cin>>t;
    ans += (t-pre<=x? t-pre:x);
    pre = t;
  }
  cout<<ans+x<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}


Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    b = deque()

    for i in range(n):
        if not i&1:
            b.append(a[i])
        else:
            b.appendleft(a[i])
    
    if not n&1:
        for i in range(n-1):
            print(b[i], end=" ")
        print(b[n-1])
    else:
        for i in range(n-1, 0, -1):
            print(b[i], end=" ")
        print(b[0])


if __name__ == "__main__":
    main()

Measured memory_bytes: 25424
import java.util.Arrays;
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
            int[] a = new int[3];
			for (int i = 0; i < 3; i++) {
            a [i] = sc.nextInt();
           } Arrays.sort(a);
             System.out.println(a[0] + " " + a[1] + " " + a[2]);
        }
}



Measured memory_bytes: 26224
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}

ll INF = 1e+18;
int iINF = 1e9;
int MAXI = 1e8 + 1;
using vec = vector<int>;

int 
main()
{
  int N; cin >> N;
  vector<vector<int>> arr(N);
  rep(i, 0, N){
    int a, b, c; cin >> a >> b >> c;
    arr[i].push_back(a);
    arr[i].push_back(b);
    arr[i].push_back(c);
  }
  vector<vector<int>> dp(N, vec(3, 0));
  dp[0][0] = arr[0][0];
  dp[0][1] = arr[0][1];
  dp[0][2] = arr[0][2];

  rep(i, 0, N - 1){
    rep(j, 0, 3){
      rep(k, 0, 3){
        if(j == k) continue;
        if(dp[i + 1][j] < dp[i][k] + arr[i + 1][j]) dp[i + 1][j] = dp[i][k] + arr[i + 1][j];
      }
    }
  }

  int ans = 0;
  rep(i, 0, 3){
    if(dp[N - 1][i] > ans) ans = dp[N - 1][i];
  }

  cout << ans << endl;

}

Measured memory_bytes: 14000
<?php
$p='';
while(1){
  list($h,$w)=explode(' ',trim(fgets(STDIN)));
  if($h||$w){
    $l='';
    for($i=0;$i<$w;$i++){$l.='#';}
    for($i=0;$i<$h;$i++){$p.=$l.PHP_EOL;}
    $p.=PHP_EOL;
  }
  else break;
}
print $p;

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

using namespace std;
using namespace __gnu_pbds;

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pii x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<pll>> vvpll;
typedef unordered_map<int, int, int_hash> umpii;
typedef unordered_map<ll, ll, int_hash> umpll;
typedef unordered_set<int, int_hash> usi;
typedef unordered_set<ll, int_hash> usll;
typedef unordered_set<pii, pair_hash> uspii;
typedef queue<int> qi;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = numeric_limits<int>::max();
const int MX = 100001; //check the limits, dummy

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

    int n; cin >> n;
    vpii v(n, {0, 0}); 
    F0R(i, n) {
        cin >> v[i].f;
        cin >> v[i].s;
    }

    sort(v.begin(), v.end(), [](const pii &p1, const pii &p2){ return p1.f + p1.s < p2.f + p2.s; });
    vvi dp(n + 1, vi(n + 1, inf));
    dp[0][0] = 0;
    int ans = 0;
    F0R(i, n) {
        F0R(j, i + 1) {
            dp[i + 1][j + 1] = min(dp[i][j + 1], v[i].f >= dp[i][j] ? dp[i][j] + v[i].s : inf);
            ans = max(ans, dp[i + 1][j + 1] == inf ? 0 : j + 1);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 98176
#include<bits/stdc++.h>
using namespace std;	
int main(){
	int n; cin>>n;
	string s, t; cin>>s>>t;
	string ans = "";
	for(int i =0; i<n; i++){
		ans += s[i];
		ans += t[i];
	}
		
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, arr[100];
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>arr[i];
    }
    int flag=1,c=0;
    for(int i=1; i<=n; i++)
    {
        if(arr[i]!=i)
        {
            c++;
            int k=arr[i];
            if(i==arr[k]){
                flag=1;
                arr[k]=arr[i];
                arr[i]=i;
            }
            else{
                flag=0;
                break;
            }
        }
    }
    if(flag==1 && c<=1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    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
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    void solve() {
        ll n;
        cin >> n;
        ll a[5];
        rep(i, 5) cin >> a[i];
        ll mv = *min_element(a, a+5);
        //cout << (ceil((n - mv)*1.0/mv)) << endl;
        ll t = 5 + (ceil((n - mv)*1.0/mv));
        cout << t << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
     */
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    if(x==y)printf("Yes");
    else if(x==2 || y==2)printf("No");
    else if((x%2==y%2)==((x<=7)==(y<=7)))printf("Yes");
    else printf("No");
    return 0;
}

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

int main() {
   int n, k;
   std::cin >> n >> k;
   std::vector<int> a(n);
   for (size_t i = 0; i < n; i++) {
      std::cin >> a.at(i);
   }
   int ans = 1;
   n -= k;
   k--;
   if(n % k == 0){
      ans += n / k;
   }else{
      ans += (n / k);
      ans++;
   }
   std::cout << ans << '\n';
}


Measured memory_bytes: 640
import sys

N = str(input())

#print(N[-1])

if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
    print('hon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
elif N[-1] == '3':
    print('bon')

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &A[i]);
  }
  ll sum = 0, ans = 0;
  for (int l = 0, r = 0; l < N; ++l) {
    while (r < N and (sum & A[r]) == 0) {
      sum ^= A[r];
      ++r;
    }
    ans += (r - l);
    if (l == r) { ++r; }
    else { sum ^= A[l]; }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1792
N=int(input())
B = list(map(int,input().split()))
mA = []
aa=0
for i in range(N-1):
    if i==0:
        mA.append(B[i])


    else:
        if B[i-1]<B[i]:
            mA.append(B[i-1])
        else:
            mA.append(B[i])


mA.append(B[N-2])
for i in range(N):
    aa+=mA[i]
print(aa)


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

ll mod_pow(ll x, ll n, ll mod)
{
    if (n == 0)
        return 1;
    ll res = mod_pow(x * x % mod, n / 2, mod);
    // x^n = ((x^2)^(n/2)) * x
    if (n & 1)
        return res = res * x % mod;
    // x^n = (x^2)^(n/2)
    return res % mod;
}

ll count1(ll bit)
{
    ll ret = 0;
    while (bit > 0)
    {
        if (bit % 2)
            ret++;
        bit /= 2;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    string x;
    cin >> x;
    ll cnt = 0;
    for (int i = 0; i < n; i++)
    {
        cnt += (x[i] == '1');
    }
    ll cntp = cnt + 1, cntm = cnt - 1;
    //cout << cntp << " " << cntm << endl;
    ll pcp = 0, pcm = 0;
    for (int i = 0; i < n; i++)
    {
        if (x[i] == '1')
        {
            pcp += mod_pow(2, (n - 1 - i), cntp);
            pcp %= cntp;
            if (cntm > 0)
            {
                pcm += mod_pow(2, (n - 1 - i), cntm);
                pcm %= cntm;
            }
        }
    }
    //cout << pcp << " " << pcm << endl;

    for (int i = 0; i < n; i++)
    {
        if (x[i] == '0')
        {
            // cntp
            ll pcp_ = pcp + mod_pow(2, (n - 1 - i), cntp);
            pcp_ %= cntp;
            ll cnt = 1;
            while (pcp_ > 0)
            {
                pcp_ = (pcp_ % count1(pcp_));
                cnt++;
            }
            cout << cnt << endl;
        }
        else
        {
            // cntm
            if (cntm == 0)
            {
                cout << 0 << endl;
            }
            else
            {
                ll pcm_ = pcm - mod_pow(2, (n - 1 - i), cntm) + cntm;
                pcm_ %= cntm;
                ll cnt = 1;
                while (pcm_ > 0)
                {
                    pcm_ = (pcm_ % count1(pcm_));
                    cnt++;
                }
                cout << cnt << endl;
            }
        }
    }
}


Measured memory_bytes: 3732
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var n int
	fmt.Scan(&n)

	ls := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ls[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(ls)))

	var points [2]int

	for i, v := range ls {
		if i%2 == 0 {
			points[0] += v
		} else {
			points[1] += v
		}
	}

	ans := points[0] - points[1]

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll k ; cin >> k ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	sort(all(a)) ;
	ll ans = 1000000000000 ;
	for(int i=0;i<n-k+1;i++){
		ans = min(ans,a.at(i+k-1)-a.at(i)) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 1024
from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))
idx = defaultdict(int)

for i in range(N):
    idx[a[i]] = i
    
m = min(a)
M = max(a)
ans = []

if abs(M)>abs(m):
    for i in range(N):
        ans.append((idx[M], i))
    
    for i in range(1, N):
        ans.append((i-1, i))
else:
    for i in range(N):
        ans.append((idx[m], i))
    
    for i in range(N-2, -1, -1):
        ans.append((i+1, i))

print(len(ans))

for x, y in ans:
    print(x+1, y+1)


Measured memory_bytes: 39664
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>

//解説ac

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
long long momm(long long  a) {
	return a * (a - 1) / 2;
}
int main()
{//ゼロツーかわいい！！！！
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) a[i]--;
	vector<int> cnt(n);
	rep(i, n) cnt[a[i]]++;
	long long tot = 0;
	rep(i, n)  //消去前のansを作り適宜消去していく
		tot += momm(cnt[i]);
	rep(i, n) {
		long long  ans = tot;
		ans -= momm(cnt[a[i]]); //まるごと消去した
		cnt[a[i]]--;
		ans += momm(cnt[a[i]]); //復元すべきところを復元した
		cout << ans << endl;
		cnt[a[i]]++;
	}
}



Measured memory_bytes: 4820
n, a, b = map(int, input().split())

MOD = 10**9 + 7
x = 1
y = 1
ans = pow(2, n, MOD) - 1

for i in range(1, b+1):
    x = x * i % MOD
    y = y * (n-i+1) % MOD
    if i == a or i == b:
        ans -= y * pow(x, MOD-2, MOD)

print(ans%MOD)

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

const LL Pt = 1e9 + 7;
int n;

int main()
{
	scanf("%d", &n);
	LL ans = 1;
	for(int i = 1; i <= n; i++) ans = (ans * i) % Pt;
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#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 PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

signed main() {
  double n, ans = 0;
  cin >> n;
  vector<double> d(n);
  rep(i, n) cin >> d.at(i);
  sort(all(d));
  for(int i = 1; i < n; i++) {
    if(d.at(i) == d.at(i-1)) continue;
    if(n/2 == i){ 
      ans += d.at(i) - d.at(i-1);
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
#define MAX 2000000
int h, a[MAX + 1];
void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;
	if (l <= h&&a[l] > a[i])largest = l;
	else largest = i;
	if (r <= h&&a[r] > a[largest])largest = r;
	if (largest != i) {
		swap(a[i], a[largest]);
		maxHeapify(largest);
	}
}
int main() {
	cin >> h;
	for (int i = 1; i <= h; i++)cin >> a[i];
	for (int i = h / 2; i >= 1; i--)maxHeapify(i);
	for (int i = 1; i <= h; i++) {
		cout << " " << a[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5028
N=int(input())
XL=[]
for _ in range(N):
    a=list(map(int,input().split()))
    XL.append(a)
XL = sorted(XL, key=lambda x:x[0]+x[1])
#前から順に取っていく
#DP[i]:i番目までのロボットで残せるロボットの最大数
#i番目のロボットがどこまでをカバーしているかを格納する必要がある
DP=[[0,0] for i in range(N)]
DP[0][0]=1#個数
DP[0][1]=XL[0][0]+XL[0][1]#カバーしている距離
for i in range(1,N):
    if XL[i][0]-XL[i][1]>=DP[i-1][1]:
        DP[i][0]=DP[i-1][0]+1
        DP[i][1]=XL[i][0]+XL[i][1]
    else:
        DP[i][0]=DP[i-1][0]
        DP[i][1]=DP[i-1][1]
print(DP[-1][0])

Measured memory_bytes: 41488
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 998244353
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
int n,s;
const int N=3005;
int dp[N][N];
int ar[N];

int rec(int ind,int done)
{
	if(done>s)
		return 0;
	if(done==s)
	{
		return n-(ind-1)+1;
	}
	if(ind>n)return 0;
	int &ans=dp[ind][done];
	if(ans>=0)return ans;

	ans=rec(ind+1,done)+rec(ind+1,done+ar[ind]);
	ans%=MOD;
	return ans;
}
int32_t main()
{
	fastio();
	memset(dp,-1,sizeof(dp));
	cin>>n;
	cin>>s;
	for(int i=1;i<=n;i++)
	{
		cin>>ar[i];
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=rec(i,0);
		ans%=MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
string joi="JOI";
string s[1000],f[2];
int cnt[1000][1000];
int main(){
	int m,n;	cin>>m>>n;
	for(int i=0;i<m;i++)	cin>>s[i];
	for(int i=0;i<2;i++)	cin>>f[i];
	int tmp=0;
	for(int i=1;i<m;i++){
		for(int j=1;j<n;j++){
			if(s[i-1][j-1]==f[0][0]&&s[i-1][j]==f[0][1]&&s[i][j-1]==f[1][0]&&s[i][j]==f[1][1]){
				tmp++;
				cnt[i-1][j-1]++;	cnt[i-1][j]++;	cnt[i][j-1]++;	cnt[i][j]++;
			}
		}
	}
	int ans=tmp;
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<3;k++){//s[i][j]をjoi[k]にした時
				int count=0;
				for(int a=-1;a<1;a++){
					for(int b=-1;b<1;b++){//左上がs[i+a][j+b]の正方形を考える
						int r=i+a,c=j+b;
						if(r<0||c<0)	continue;
						if(r+1>=m||c+1>=n)	continue;
						string ts[]={"  ","  "};
						for(int y=0;y<2;y++){
							for(int x=0;x<2;x++){
								if(r+y==i&&c+x==j)	ts[y][x]=joi[k];
								else 	ts[y][x]=s[r+y][c+x];
							}
						}
						if(ts[0]==f[0]&&ts[1]==f[1])	count++;
					}
				}
				ans=max(ans,tmp-cnt[i][j]+count);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6176
import numpy as np

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

S1 = (A1 - B1) * T1
S2 = (A2 - B2) * T2

if (S1 + S2) == 0:
    print('infinity')
elif np.sign(S1) == np.sign(S2):
    print(0)
elif abs(S1) > abs(S2):
    print(0)
else:
    z = 1 + ((abs(S1)) // abs(S1 + S2)) * 2
    if (abs(S1)) % abs(S1 + S2) == 0:
        z = z -1
    print(z)


Measured memory_bytes: 21148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int binarySearch(int key, int N, int A[]){
	int left = 0;
	int right = N;
	int mid;
	while(left < right){
		mid = (left + right)/2;
		if( key < A[mid] ) right = mid;
		else if( A[mid] < key) left = mid + 1;
		else if( A[mid] == key) return 1;
	}
	return 0;
}

 
 int main(){
 	int N;
 	int S[200000];
 	int q;
 	int T[50000];
 	int count = 0;

 	cin >> N;
 	for(int i = 0; i < N; i++){
 		cin >> S[i];
 	}
 	cin >> q;
 	for(int j = 0; j < q; j++){
 		cin >> T[j];
 	}

 	for(int j = 0; j < q; j++){
 		if( binarySearch(T[j], N, S) ) count++;
 	}

 	cout << count << endl;

 	return 0;
 }

Measured memory_bytes: 1748