akhauriyash/Code-Regression huggingface dataset:
/*
Author : N_o_o_B
Created : April 22 2020 15:34:44 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,m,c;
    cin >> n >> m >> c;
    vi b(m);
    fori(i,m) cin >> b[i];
    int ans = 0;
    while(n--){
        ll sum = 0;
        fori(i,m){
            int x;
            cin >> x;
            sum += b[i]*x;
        }
        sum += c;
        ans += (sum > 0);
    }
    cout << ans << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1'000'000'007;
// const ll MOD = 998244353;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll D, T, S;
    cin >> D >> T >> S;
    cout << ((D + S - 1) / S <= T ? "Yes" :"No") << endl;
}


Measured memory_bytes: 3648
/**
 *      ABC 85 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-01 04:48:44
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    vector<int> d;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        d.push_back(x);
    }
    int count = 1;
    sort(d.begin(), d.end());
    for (int i = 0; i < N - 1; ++i){
        if (d[i] < d[i + 1]) {
            ++count;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int N; cin >> N;
  if (N % 2 == 0) {
    cout << (N-2) * N / 2 << endl;
    for (int i = 1; i < N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i + j != N+1) {
          cout << i << ' ' << j << endl;
        }
      }
    }
  }

  else {
    cout << (N-1) * (N-1) / 2 << endl;
    for (int i = 1; i < N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (j != N && i + j != N) cout << i << ' ' << j << endl;
        if (j == N) cout << i << ' ' << j << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
    };

    // 2次元用の標準入出力
    template<typename T>
    struct inpn {
        std::size_t szi, szj;
        inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
        operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i)
                for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
            return a;
        }
    };

    inp inp1; // input one
}


int main() {

    vector<int> w = inp(10);
    vector<int> s = inp(10);

    sort(allof(w), greater<int>());
    sort(allof(s), greater<int>());

    int first = w[0] + w[1] + w[2];
    int second = s[0] + s[1] + s[2];

    cout << first << " " << second << endl;

    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
using namespace std;
int f(int x, int y){
    return x ? f(y%x,x) : y;
}
int main () {
    int a, b, k, N=0, cnt=0;
    cin >> a >> b >> k;
    N=f(a,b);
    for (cnt=N;k>0;cnt--){
        if (N%cnt==0)
            k--;
    }
    cout << cnt+1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<vector<int>> bp(N + 1, vector<int>(0));
    for (int i = 1; i < N + 1; i++){
        if (i != N) bp.at(i).push_back(i + 1);
        if (i != 1) bp.at(i).push_back(i - 1);
    }
    bp.at(X).push_back(Y);
    bp.at(Y).push_back(X);
   
    vector<int> ans(N, 0);
    for (int k = 1; k <= N; k++){
        vector<int> d(N + 1, INF);
        d.at(k) = 0;
        queue<int> q;
        q.push(k);
        while(!q.empty()){
            int start = q.front();
            q.pop();
            for (int i = 0; i < bp.at(start).size(); i++){
                int way = bp.at(start).at(i);
                if (d.at(way) == INF){
                    q.push(way);
                    d.at(way) = d.at(start) + 1;
                    ans.at(d.at(way)) ++;
                }
            }
        }
    }
    for (int i = 1; i <= N - 1; i++){
        cout << ans.at(i) / 2 << endl;
    }
}

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

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

    sort(a.begin(), a.end(), greater<int>());
    int A = 0;
    for (int i = 0; i < n; i += 2) {
        A += a.at(i);
    }
    int B = 0;
    for (int i = 1; i < n; i += 2) {
        B += a.at(i);
    }

    cout << A - B << endl;
}

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


int N, K;


void input() {
    cin >> N >> K;
}


int main() {
    input();
    int ans = 1;
    ll x = K;
    while (x <= N) {
        ans++;
        x *= K;
    }
    cout << ans << endl;
}


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


int main() {
  int r, d, x;
  cin >> r >> d >> x;
 
  rep(i,10){
    cout << r * x - d << endl;
    x = r * x - d;
  }
    
  return 0;
}




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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
vector<P> V;

void solve(){

  ll ans = (1LL<<60);

  for(int i = 0; i < V.size(); i++)
    for(int j = i+1; j < V.size(); j++){
      ll x = V[j].first-V[i].first;
      ll y = V[j].second-V[i].second;
      if(x*x > ans) break;
      ans = min(ans,x*x+y*y);
    }
  cout << ans << endl;
}

int main(){

  int n;
  cin >> n;
  while(n--){
    P p;
    cin >> p.first >> p.second;
    V.push_back(p);
  }
  sort(V.begin(),V.end());
  solve();
  return 0;
}

Measured memory_bytes: 10780
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define iiordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define MOD 998244353
ll power(ll a,ll b, ll m=MOD)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll inverse(ll a,ll m=MOD)
{
    return power(a,m-2,m);
}
int ceil(int a,int b)
{
    return (a+b-1)/b;
}
#define INFl (1e18+5)
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<long long>
#define vvl vector<vl>
#define vll vector<pll>
#define vii vector<ii>
#define vvii vector<vii>
#define tri pair<int,ii>
#define F first
#define S second
#define forl(i,n) for(int i=0;i<n;i++)
#define fore(i,n) for(int i=1;i<=n;i++)
#define rforl(i,n)  for(int i=n-1;i>=0;i--)
#define rfore(i,n)  for(int i=n;i>=1;i--)
#define CASE(t) cout<<"Case #"<<(t)<<": ";
#define INF 1020000000
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<it->F<<' '<<it->S<<endl;  
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

ll dp[3005][3005];
int main()
{
	int n,s;
	cin>>n>>s;
	ll ans=0;
	vi a(n);
	forl(i,n)	cin>>a[i];
	dp[n][0]=1;
	for(int i=n-1;i>=0;i--)
	{
		for(int x=0;x<=s;x++)
		{
			dp[i][x]=dp[i+1][x];
			if(x==a[i])
				dp[i][x]=(dp[i][x]+n-i)%MOD;
			else if(x>a[i])
				dp[i][x]=(dp[i][x]+dp[i+1][x-a[i]])%MOD;
		}
		// forl(x,s+1)
		// {
			// cout<<dp[i][x]<<' ';
		// }
		// cout<<endl;
		ans+=dp[i][s];
		// cout<<ans<<endl;
		ans%=MOD;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 70656
#include <iostream>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

const int H = 5, W = 4;

inline int countZero(const string &str) {
  int ret = 0;
  for(int i=0; i<H*W; i++) {
    ret += str[i] == '0';
  }
  
  return ret;
}

/*
void rearrange(string &str) {
  int pos = 0;
  for(int i=0; i<H*W; i++) {
    if(str[i] == '0') continue;
    char ch = str[i];
    str[i] = '0';
    str[pos++] = ch;
  }
}
*/

int main() {
  
  int Tc;
  cin >> Tc;
  
  while(Tc--) {
    
    string initial;
    for(int i=0; i<H; i++) {
      for(int j=0; j<W; j++) {
        char ch; cin >> ch;
        initial += ch;
      }
    }
    
    int ans = 0;
    
    set<string> used;
    queue<string> Q;
    Q.push(initial);
    while(!Q.empty()) {
      const string now = Q.front(); Q.pop();
      ans = max(ans, countZero(now));
      for(int pos=0; pos<H*W; pos++) {
        if(now[pos] == '0') continue;
        int x = pos%W, y = pos/W;
        for(int k=0; k<=1; k++) {
          for(int l=-1; l<=1; l++) {
            if(k == 0 && l == 0) continue;
            const int ny = y+k, nx = x+l;
            if(nx<0 || W<=nx || ny<0 || H<=ny) continue;
            const int npos = ny*W+nx;
            if(now[pos] != now[npos]) continue;
            string next;

            for(int i=0; i<H*W; i++) {
              if(i == pos || i == npos) continue;
              next += now[i];
            }
            next += "00";
            
            //next = now; next[pos] = next[npos] = '0'; rearrange(next);
            
            if(used.count(next)) continue;
            used.insert(next);
            Q.push(next);
          }
        }
      }
    }
    cout << 20-ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1332
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef unsigned long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

vll W, V;
ll H, N;
unordered_map<ll,ll> dp;

ll eval() {
	for (int i = 1; i <= H; ++i) {
		ll &curr = dp[i];
		curr = INT_MAX;
		for (int j = 0; j < N; ++j) {
			curr = min(curr, dp[i-W[j]] + V[j]);
		}
	}
	return dp[H];
}

int main() {
	scll(H), scll(N);
	W.resize(N), V.resize(N);
	for (int i = 0; i < N; ++i) {
		scll(W[i]), scll(V[i]);
	}
	printf("%lld\n", eval());
	return 0;
}

Measured memory_bytes: 768
from operator import itemgetter
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
  l[i]=[l[i][0],l[i][1],(l[i][0]+l[i][1])/2]
len=[]
for i in range(n):
  len.append(l[i][1]-l[i][0]+1)
maxlen=max(len)
x=len.index(maxlen)
L3=1;R3=10**9
for i in range(n):
  if l!=x:
    L3=max(L3,l[i][0])
    R3=min(R3,l[i][1])
c=maxlen+max(R3-L3+1,0)

l=sorted(l,key=itemgetter(2))
L=[]
R=[]
for i in range(n):
  L.append(l[i][0])
for i in range(n):
  R.append(l[i][1])
L1=1;R1=10**9
L2=1;R2=10**9
list=[]
list2=[]
for i in range(n-1):
  L1=max(L1,l[i][0])
  R1=min(R1,l[i][1])
  list.append(max(R1-L1+1,0))
for i in range(n-1,0,-1):
  L2=max(L2,l[i][0])
  R2=min(R2,l[i][1])
  list2.append(max(R2-L2+1,0))

list2.reverse()
ans=[]
for i in range(n-1):
  ans.append(list[i]+list2[i])
a=max(ans)
print(max(a,c))

Measured memory_bytes: 42596
using System;

public class P
{
    public int a { get; set; }
    public int b { get; set; }
}

public class Hello
{
    public const int INF = 999999999;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var ps = new P[m ];
        var dp = new int[n, n];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (i != j) dp[i, j] = INF;
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]) - 1;
            var b = int.Parse(line[1]) - 1;
            dp[a, b] = 1;  dp[b, a] = 1;
            ps[i] = new P { a = a, b = b };
        }
        Console.WriteLine(getAns(dp, ps));
    }
    public static int getAns (int[,] dp ,  P[] ps)
    {
        var n = dp.GetLength(0);
        var dp2 = new int[n, n];
        var count = 0;
        for (int i = 0; i < ps.Length; i++)
        {
            Array.Copy(dp, dp2, dp.Length);
            var na = ps[i].a;
            var nb = ps[i].b;
            dp2[na, nb] = INF;   dp2[nb, na] = INF;
            goWarshall(dp2);
            if (dp2[na, nb] == INF) count++;
        }
        return count;
    }
    public static void goWarshall(int[,] dp)
    {
        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    dp[j, k] = Math.Min(dp[j, k], dp[j, i] + dp[i, k]);
    }
}


Measured memory_bytes: 15284
n = int(input())
a = list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[i]%2==0:
        if a[i]%3==0:
            pass
        elif a[i]%5==0:
            pass
        else:
            cnt+=1
if cnt==0:
    print("APPROVED")
else:
    #print(cnt)
    print("DENIED")

Measured memory_bytes: 9152
N,K = [int(x) for x in input().split()]
#%%
cnt = 0
if(K==0):
    print(N**2)
else:
    for i in range(K+1,N+1):
        x = i-K
        y = N // i
        cnt += x*y + max(0,N%i-K+1)
    print(cnt)


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    set<int> a;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        a.insert(tmp);
    }
    if (a.size() == n) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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

#define ll long long
#define COMBI_SIZE 1000

// 自然数xをn進法で表現した時の桁数
ll digit(ll x, ll n)
{
    ll i = 1;
    for(i = 0;0 < x;i++) {
        x /= n;
    }
    return i;
}

// xが素数かどうか
bool isprime(ll x)
{
    if(x == 1)return false;
    if(x == 2)return true;
    if(x%2 == 0)return false;

    for(ll i = 3;i*i <= x;i += 2) {
        if(x%i == 0)return false;
    }
    return true;
}


bool combi_init = false;
ll combi_memo[COMBI_SIZE][COMBI_SIZE];
// nCr
ll combi(ll n, ll r)
{
    if(!combi_init) {
        combi_init = true;
        for(ll i = 0;i < COMBI_SIZE;i++) {
            for(ll j = 0;j < COMBI_SIZE;j++) {
                combi_memo[i][j] = i == j || j == 0;
            }
        }
    }

    if(n < 0) {
        return 0;
    }
    if(n < r) {
        return 0;
    }

    if(combi_memo[n][r] == 0) {
        combi_memo[n][r] = combi(n - 1, r - 1) + combi(n - 1, r);
    }
    return combi_memo[n][r];
}

int main()
{
    ll N;
    scanf("%lld", &N);
    vector<ll> v;
    v.resize(N + 1);
    for(ll i = 0;i <= N;i++) {
        v[i] = 0;
    }
    for(ll i = 2;i <= N;i++) {
        ll m = i;
        for(ll j = 2;j <= N;j++) {
            if(!isprime(j))continue;
            for(;m%j == 0;m /= j)v[j]++;
        }
    }

    ll x = 0;

    for(ll i = 0;i <= N;i++)
        if(2 <= v[i])
            for(ll j = 0;j <= N;j++)
                if(4 <= v[j] && i != j)
                    for(ll k = 0;k <= N;k++)
                        if(4 <= v[k] && i != k && j != k)
                            x++;
    x /= 2;
    for(ll i = 0;i <= N;i++)
        if(2 <= v[i])
            for(ll j = 0;j <= N;j++)
                if(24 <= v[j] && i != j)
                    x++;
    for(ll i = 0;i <= N;i++)
        if(4 <= v[i])
            for(ll j = 0;j <= N;j++)
                if(14 <= v[j] && i != j)
                    x++;
    for(ll i = 0;i <= N;i++)
        if(74 <= v[i])
            x++;

    printf("%lld\n", x);
    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def swap(l):
    cnt = 0
    now = list(range(n))
    for i in range(n):
        c = l[n-i-1]
        n_ind = now.index(c)
        # print(n_ind)
        cnt += abs((n-i-1)-n_ind)
        if (n-i-1)-n_ind == 0:
            continue
        now.remove(c)
        # print(now)
        now.insert(n-i-1,c)
        # print(now)
    return cnt

n = inp()
a = inpl()
b = inpl()
card = []
res = INF
for i in range(n):
    card.append([a[i],b[i],i])
for flag in itertools.combinations(range(n),(n+1)//2):
    # print(flag)
    f = True
    odd_li = []
    odd_ind = [False] * n
    for i,bit in enumerate(flag):
        c = 1 if bit%2 else 0
        odd_li.append([card[bit][c],bit])
        odd_ind[bit] = True
    if not f:
        continue
    odd_li.sort()
    even_li = []
    for i in range(n):
        c = 0 if i%2 else 1
        if not odd_ind[i]:
            even_li.append([card[i][c],i])
    even_li.sort()
    # print(odd_li,even_li)

    if n%2:
        for i in range(n//2):
            if odd_li[i][0] <= even_li[i][0] <= odd_li[i+1][0]:
                continue
            else:
                f = False; break
    else:
        for i in range(n//2):
            if i != n//2-1:
                if odd_li[i][0] <= even_li[i][0] <= odd_li[i+1][0]:
                    continue
                else:
                    f = False; break
            else:
                if odd_li[-1][0] <= even_li[-1][0]:
                    continue
                else:
                    f = False; break

    if f:
        after_ind = []
        for i in range(n//2):
            after_ind.append(odd_li[i][1])
            after_ind.append(even_li[i][1])
        if n%2:
            after_ind.append(odd_li[-1][1])
        # print(odd_li,even_li)
        # print(after_ind)
        res = min(res,swap(after_ind))
print(-1 if res == INF else res)

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

int main(){
  ll M, N, i;
  string ans = "No";
  cin >> M >> N;
  if(M == N){
    ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}

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

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

  int ans[n]= {};

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

Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
long long h,w;
void solve()
{
    getchar();
    long long i,j,b[h][w],c[h][w];
    char a[h][w];
    for (i=0;i<h;i++)
    {
        for (j=0;j<w;j++)
        {
            c[i][j]=0;
            a[i][j]=getchar();
        }
        getchar();
    }
    for (i=0;i<h;i++)
        for (j=0;j<w;j++)
            if (a[i][j]=='.') b[i][j]=0;
            else b[i][j]=1;
    for (i=0;i<h;i++)
        if (!b[i][0]) c[i][0]=1;
        else break;
    for (i=0;i<w;i++)
        if (!b[0][i]) c[0][i]=1;
        else break;
    for (i=1;i<h;i++)
        for (j=1;j<w;j++)
            if (!b[i][j]) c[i][j]=(c[i-1][j]+c[i][j-1])%MOD;
            else c[i][j]=0;
    cout<<c[h-1][w-1]<<endl;
}
int main()
{
    cin>>h>>w;
    solve();
}

Measured memory_bytes: 16896
var input = require("fs").readFileSync("/dev/stdin", "utf8");

var words = input.split(' ');
var A = Number(words[0]);
var B = Number(words[1]);

var result;
if (A >= 10 || B >= 10) {
    result = -1;
} else {
    result = A * B;
}
console.log(result);


Measured memory_bytes: 9420
# coding: utf-8

n = int(input())
a = list(map(int, input().split()))
a_ = [0] * n
for i in range(n):
    a_[i] = abs(a[i])

output = 0
all_plus = False
minus_kisuu = False
for i in range(n):
    if a[i] == 0:
        all_plus = True
        break
    if a[i] < 0:
        minus_kisuu = not minus_kisuu

if all_plus or not minus_kisuu:
    for i in range(n):
        output += a_[i]
else:
    for i in range(n):
        output += a_[i]
    output -= min(a_) * 2

print(output)


Measured memory_bytes: 14412
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        String[] input = Console.ReadLine().Split();
        int[] A = new int[N];
        for(int i = 0; i < N-1; i++)
        {
            A[int.Parse(input[i])-1]++;
        }
        for(int i = 0; i < N; i++)
        {
            Console.WriteLine(A[i]);
        }
    }
}

Measured memory_bytes: 42156
class Node:
    def __init__(self, num, deg, neib):
        self.num = num
        self.deg = deg
        self.neib = neib


dnum = int(input())
N = []
for i in range(dnum):
    data = input().split()
    
    u = int(data[0])
    k = int(data[1])
    if k > 0:
        v = list(map(int, data[2:]))
        node = Node(u,k,v)
    else:
        node = Node(u,k,0)

    N.append(node)

O = []
for e in N:
    out = [0]*dnum
    if e.neib != 0:
        for j in e.neib:
            out[j-1] = 1
    else: pass

    O.append(out)

for i in O:
    print(*i)



Measured memory_bytes: 6380
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
vector<int> d(4);
string s="";
bool dfs(int n,string s,int sum){
  if(n==4)  return sum ==7;
  if(dfs(n+1,s,sum+d[n])){
    s[n-1] = '+'; return true;
  }
  if(dfs(n+1,s,sum-d[n])){
    s[n-1] = '-'; return true;
  }
  return false;
}
    
    

int main(){
  int n;
  cin >> n;
  int a = 3;
  while(a>=0){
	d.push_back(n%10);
    n/=10;
    a--;
  }
  reverse(d.begin(),d.end());
  if(dfs(1,s,d[0])){
    //cout << s << endl;
    rep(i,3){
      cout << d[i] << s[i];
    }
    cout << d[3];
  }
  cout << "=7" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if (x >= r&&x<=w - r&&y>=r&&y <= h - r){
		cout << "Yes"<<endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define rt return
#define ENDL cout<<endl
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; }

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    int N;cin >> N;
    vector<int> vec;
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        vec.push_back(b);
    }
    vec.erase(unique(vec.begin(),vec.end()),vec.end());
    vector<LL> dp(vec.size()),sum(1e5*2+1);
    sum[vec.front()]++;
    for(int i = 0;i < vec.size();i++){
        if(i != 0)sum[vec.at(i)]+=dp[i-1]%MOD;
        if(sum[vec.at(i)] == 0)dp[i] = 1;
        else dp[i] = sum[vec.at(i)]%MOD;
        dp[i]%=MOD;
        sum[vec.at(i)]%=MOD;
    }
    for(int a = 0;a < dp.size();a++){
       // cout<<a<<":"<<dp[a]<<endl;
    }
    for(int a = 0;a < 10;a++){
       // cout<<a<<":"<<sum[a]<<endl;
    }
    cout<<dp[vec.size()-1]<<endl;
}


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

int main(){
    int N;
    long a;
    map<long, int> mp;
    long long ans = 0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a;
        mp[a]++;
    }
    for(auto m: mp){
        if(m.second > m.first){
            ans += m.second - m.first;
        }
        else if(m.second < m.first){
            ans += m.second;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define debug(...) cerr << "[" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "]\n"

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

	int N;
	cin >> N;
	vector<int> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];
	vector<ll> dp(N, 1e18);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; i++) {
		for (int j = 1; j <= 2; j++) {
			dp[i] = min(abs(h[i] - h[i - j]) + dp[i - j], dp[i]);
		}
	}
	cout << dp[N - 1];	

	return 0;
}	

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

int main(){
    ll H, W, N; cin >> H >> W >> N;
    vector<P> point(N);
    rep(i, N) cin >> point[i].first >> point[i].second;

    vector<ll> ans(10);
    map<pair<ll, ll>, ll> mp;
    rep(i, N){
        rep(j, 3){
            rep(k, 3){
                if(point[i].first - j >= 1 && point[i].first - j <= H - 2 && point[i].second - k >= 1 && point[i].second - k <= W - 2){
                    mp[{point[i].first - j , point[i].second - k}]++;
                }
            }
        }
    }
    for(auto e: mp){
        //cout << e.first.first << " " << e.first.second << " " << e.second << endl;
        ans[e.second]++;
    }
    ans[0] = (H - 2) * (W - 2);
    for(int i = 1; i < 10; i++) ans[0] -= ans[i];

    rep(i, 10){
        cout << ans[i] << endl;
    }

}

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

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			string s = cin.Next();
			int ans = 0;
			int now = 0;
			for (int i = 0; i < s.Length; i++)
			{
				if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
				{
					now++;
				}
				else
				{
					now = 0;
				}
				ans = Math.Max(now, ans);
			}
            Console.WriteLine(ans);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 2000005;

int add(int a, int b){
	a += b;
	if(a >= mod) a -= mod;
	return a;
}

int mul(int a, int b){
	return 1ll * a * b % mod;
}

int pwr(int a, int b){
	int r = 1;
	for(; b; b>>=1, a = mul(a,a))
		if(b&1)
			r = mul(r, a);
	return r;
}

int fact[N], ifact[N];

void init(){
	fact[0] = 1;
	for(int i = 1; i < N; i++)
		fact[i] = mul(i, fact[i-1]);
	ifact[N-1] = pwr(fact[N-1], mod-2);
	for(int i = N-2; i >= 0; i--)
		ifact[i] = mul(ifact[i+1], i+1);
}

int ncr(int n, int r){
	if(n < r) return 0;
	return mul(fact[n], mul(ifact[r], ifact[n-r]));
}

void solve(){
	init();
	int k;
	string s;
	cin >> k >> s;
	int sum = 0, len = k + sz(s);
	for(int m = 0; m < sz(s); m++){
		sum = add(sum, mul(ncr(len, m), pwr(25, len-m)));
	}
	int total = pwr(26, len);
	total = add(total, -sum+mod);
	cout << total << '\n';
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


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

using namespace std;

int main(int argc, char* argv[]) {
  int N, D;
  cin >> N >> D;

  int points[N][D];

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < D; ++j) {
      cin >> points[i][j];
    }
  }

  int ret = 0;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int d = 0;
      for (int k = 0; k < D; ++k)
        d += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);
      float norm = sqrt(d);
      if (int(norm) == norm)
        ++ret;
    }
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, Ai, Bi;
    cin >> N;
    vector<ll> A, B;
    vector<ll> diff;
    ll sumLoss = 0;
    for(int i=0;i<N;i++){
        cin >> Ai;
        A.push_back(Ai);
    }
    for(int i=0;i<N;i++){
        cin >> Bi;
        B.push_back(Bi);
    }

    ll count = 0;
    for(int i=0;i<N;i++){
        diff.push_back(A[i]-B[i]);
        if(A[i] < B[i]){
            sumLoss += B[i]-A[i];
            count++;
        }
    }
    sort(diff.begin(), diff.end(), std::greater<ll>());

    if(sumLoss<=0){
        cout<<count<<endl;
        return 0;
    }

    for(int i=0;i<N;i++){
        count++;
        if(diff[i]>0){
            sumLoss -= diff[i];
            if(sumLoss<=0){
                cout<<count<<endl;
                return 0;
            }
        }else{
            break;
        }
    }

    cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 3316
#include <stdio.h>
const int N=1e5+10;
int main(){
    int n,a[N],l,r,mid,q,temp;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    scanf("%d",&q);
    while(q--){
        scanf("%d",&temp);
        if(a[n-1]<temp)printf("%d\n",n);
        else if(a[0]>=temp)printf("0\n");
        else{
            l=0;
            r=n-1;
            while(r-l>1){
                mid=(r+l)>>1;
                if(a[mid]>=temp)r=mid;
                else l=mid;
            }
            printf("%d\n",r);
        }
    }
}


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

int main(){
    string s ;
    getline(cin,s) ;
    for(int i=0;i<s.size();i++){
        if('a'<=s.at(i)&&s.at(i)<='z') s.at(i) += 'A'-'a' ;
        else if('A'<=s.at(i)&&s.at(i)<='Z') s.at(i) += 'a'-'A' ;
    }
    cout << s << endl ;
}


Measured memory_bytes: 3192
s=readline()

hantei1=false
hantei2=false
let
for i in 1:length(s)
    hantei1=hantei1?true:is(s[i],'C')
    hantei2=hantei1?(hantei2||is(s[i],'F')):false
end
end
answer=hantei2?"Yes":"No"
println(answer)

Measured memory_bytes: 95860
#include <iostream>
#include <unordered_map>
using namespace std;
 
int main() {
    
    int n;
    cin >> n;
    
    unordered_map<int,int>m;
    for (int i =0; i<n; i++) {
        int a;
        cin >> a;
        if(m.find(a)!=m.end()) {
            m[a]++;
        } else {
            m[a]=1;
        }
    }
    
    int valid=1;
    
    if (n%2 != 0) {
        int i=0;
        while(i <= n-1) {
            if(m.find(i)!=m.end()) {
                if(i==0 && m[i]!=1) {
                    valid=0;
                    break;
                }
                if(i!=0 && m[i]!=2) {
                    valid=0;
                    break;
                }
            } else {
                valid=0;
                break;
            }
            i=i+2;
        }
    } else {
        int i=1;
        while(i <= n-1) {
            if(m.find(i)!=m.end()) {
                if(m[i]!=2) {
                    valid=0;
                    break;
                }
            } else {
                valid=0;
                break;
            }
            i=i+2;
        }
    }
    
    if(!valid) {
        cout << 0 << endl;
        return 0;
    }
    
    int k =0;
    if (n%2 == 0) {
        k = m.size();
    } else {
        k = m.size()-1;
    }
    
    long long ans = 1;
    for (int i=0; i<k; i++) {
        ans = ans << 1;
        ans = ans % (int)(1e9+7);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3596
/*********************************************************************/
/* ABC 143 A */
/*********************************************************************/
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int A, B; cin >> A >> B;
    cout << (A <= 2 * B?0:A-2*B) << endl;
	return 0;
}

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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int H[N];
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }

    sort(H, H + N, greater<>());
    int ans = INT_MAX;
    for (int i = 0; i < N; ++i) {
        if (i + K - 1 >= N) break;
        ans = min(ans, H[i] - H[i + K - 1]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    int s;
    cin >> s;
    int i = 1;
    set<int> a;
    int t = s;
    a.insert(s);
    while (true) {
        i++;
        if (t % 2) {
            t = 3 * t + 1;
            if (a.find(t) != a.end())
                break;
            a.insert(t);
        }
        else {
            t /= 2;
            if (a.find(t) != a.end())
                break;
            a.insert(t);
        }
    }
    cout << i << endl;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		int x =sc.nextInt();
		int y =sc.nextInt();
		int z =sc.nextInt();
		int k =sc.nextInt();
		long a[] =new long[x];
		long b[] =new long[y];
		long c[] =new long[z];
		for(int i=0;i<x;i++) {
			a[i] = sc.nextLong();
		}
		for(int i=0;i<y;i++) {
			b[i] = sc.nextLong();
		}
		for(int i=0;i<z;i++) {
			c[i] = sc.nextLong();
		}
		long ab[]= new long[1000000];
		for(int i=0;i<x;i++) {
			for(int j=0;j<y;j++) {
				ab[i*y+j]=a[i]+b[j];
			}
		}
		
		Arrays.sort(ab);
		long abc[]=new long[3000000];
		for(int i=0;i<3000;i++) {
			for(int j=0;j<z;j++) {
				abc[i*z+j]=ab[999999-i]+c[j];
			}
		}
		Arrays.sort(abc);
		
		for(int i=0;i<k;i++) {
		System.out.println(abc[2999999-i]);
		}
		
	}

}





Measured memory_bytes: 62400
object Main extends App {
  io.StdIn.readLine()
  val input = io.StdIn.readLine().split(' ').toVector.map(_.toInt)
  val getResult: Seq[Int] => Boolean = list => list.foldLeft((1, true)) { case (acc, current) =>
    val prevMax = acc._1
    val judge = current >= prevMax - 1
    (math.max(prevMax, current),  acc._2 && judge)
  }._2

  if (getResult(input)) println("Yes") else println("No")
}

Measured memory_bytes: 48812
import math
n, m = map(int, input().split())
ret = 1
mod = 10 ** 9 + 7
ret *= math.factorial(n)
ret %= mod
ret *= math.factorial(m)
ret %= mod

if m < n:
    n, m = m, n

if m - n > 1:
    print(0)
else:
    ret *= 2 - (m - n)
    ret %= mod
    print(ret)


Measured memory_bytes: 4132
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

typedef tuple<int,int,int,int> T;
map<T, int> memo;
int grundy(vector<vector<char>>& m, T t){
	if(memo.count(t)) return memo[t];

	int lx, ly, rx, ry;
	tie(lx, ly, rx, ry) = t;

	set<int> s;
	range(i,ly,ry){
		range(j,lx,rx){
			if(m[i][j] == 'X') continue;
			vector<T> a(4);
			a[0] = T(lx, ly, j, i);
			a[1] = T(j + 1, ly, rx, i);
			a[2] = T(lx, i + 1, j, ry);
			a[3] = T(j + 1, i + 1, rx, ry);

			int x = 0;
			//rep(k,4){
			//		int q,w,e,r;
			//		tie(q,w,e,r) = a[k];
			//		cout << q << w << e << r << endl;
			//}
			//		cout << endl;
			rep(k,4){
				if(get<2>(a[k]) > get<0>(a[k]) and get<3>(a[k]) > get<1>(a[k])){
					x ^= grundy(m, a[k]);
				}
			}
			s.emplace(x);
		}
	}

	int k = 0;
	while(s.count(k)) k++;
	return memo[t] = k;
}

int main(){
	int h, w;
	cin >> h >> w;

	vector<vector<char>> m(h, vector<char>(w));
	rep(i,h){
		rep(j,w){
			cin >> m[i][j];
		}
	}

	cout << (grundy(m, T(0, 0, w, h)) != 0 ? "First" : "Second") << endl;
}



Measured memory_bytes: 5828
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))

max_dig=50

dp=[[-1]*2 for _ in range(max_dig+1)]

dp[0][0]=0

for d in range(max_dig):
    mask=1<<(max_dig-d-1)

    cnt=sum([mask&a[i]>0 for i in range(n)])
    c0=cnt*mask
    c1=(n-cnt)*mask

    if dp[d][1]!=-1:
        dp[d+1][1]=max(dp[d+1][1],dp[d][1]+max(c0,c1))
    
    if dp[d][0]!=-1:
        if k&mask>0:
            dp[d+1][1]=max(dp[d+1][1],dp[d][0]+c0)
    
    if dp[d][0]!=-1:
        if k&mask>0:
            dp[d+1][0]=max(dp[d+1][0],dp[d][0]+c1)
        else:
            dp[d+1][0]=max(dp[d+1][0],dp[d][0]+c0)

print(max(dp[max_dig][0],dp[max_dig][1]))
    

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

int main() {
  int n;
  while(cin >> n && n!=0) {
    vector<int> a;
    for(int i=0; i<n; i++) {
      int x;
      cin >> x;
      a.push_back(x);
    }
    sort(a.begin(), a.end(), greater<int>() );
    a.erase(remove(a.begin(),a.end(),0),a.end());
    if(*a.begin()<2) cout << "NA" << endl;
    else cout << a.size()+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1324
h,w = map(int, raw_input().split(' '))
def f(h,w):
	if h == 1 or w == 1:
		return 1
	x = w - w/2
	y = w/2
	count = 0
	count += (h - (h/2)) * x
	count += ((h/2)) * y
	return count
		


print f(h,w)

Measured memory_bytes: 27884
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <cmath>

#include <queue>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 20, MOD = 1e9 + 7;
int N, M, dp[MN], ret;
vector<int> adj[MN];

int dfs(int u) {
    if (~dp[u]) return dp[u];
    dp[u] = 0;
    for (int v : adj[u])
        dp[u] = max(dp[u], dfs(v) + 1);
    ret = max(ret, dp[u]);
    return dp[u];
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N >> M;
    for (int i = 0, u, v; i < M; i++) {
        cin >> u >> v;
        adj[u].push_back(v);
    }
    memset(dp, -1, sizeof(dp));
    for (int i = 1; i <= N; i++) dfs(i);
    cout << ret << '\n';
    return 0;
}


Measured memory_bytes: 7424