akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    map<char,ll> M;
    for(ll i=0;i<N;++i){
        string S;
        cin >> S;
        M[S[0]]++;
    }
    vector<char> vec={'M','A','R','C','H'};
    ll ans=0;
    for(ll i=0;i<3;++i)
        for(ll j=i+1;j<4;++j)
            for(ll k=j+1;k<5;++k){
                ans+=(M[vec[i]]*M[vec[j]]*M[vec[k]]);
            }
    prt(ans)
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
int top,S[10000];
 
void push(int x){
  S[++top]=x;
}
 
int pop(){
 return S[top--];
}
 
int main(){
  int a,b;
  char s[1];
  top=0;
   
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      b=pop();
      a=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      b=pop();
      a=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 548
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
#define p 998244353
using namespace std;
inline ll read(){
    ll x = 0; char zf = 1; char ch = getchar();
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt,sum;
struct drin{
	ll x,y;
	bool operator <(const drin s)const{
		return x<s.x;
	}
}a[100010];
int main(){
	n=r;m=r;
	for(rt i=1;i<=n;i++)a[i].x=r,a[i].y=r;
	sort(a+1,a+n+1);ll cos=0;
	for(rt i=1;i<=n;i++){
		if(m>=a[i].y)cos+=a[i].x*a[i].y,m-=a[i].y;
		else cos+=m*a[i].x,m=0;
		if(!m)break;
	}
	cout<<cos;
    return 0;
}








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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  string a, b;
  std::cin >> a >> b;
  if (a.size() > b.size()) {
    std::cout << "GREATER" << std::endl;
    return 0;
  } else if (a.size() < b.size()) {
    std::cout << "LESS" << std::endl;
    return 0;
  }
  REP(i, a.size()) {
    if (a[i] > b[i]) {
      std::cout << "GREATER" << std::endl;
      return 0;
    } else if (a[i] < b[i]) {
      std::cout << "LESS" << std::endl;
      return 0;
    }
  }
  std::cout << "EQUAL" << std::endl;
}

Measured memory_bytes: 256
a,b,m=map(int,input().split())
la=list(map(int,input().split()))
lb=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(m)]

ll=[] 
for i in range(m):
    ll.append(la[l[i][0]-1]+lb[l[i][1]-1]-l[i][2])

ll.append(min(la)+min(lb))
print(min(ll))


Measured memory_bytes: 42400
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main() {
    ll N,cnt=0;
    cin>>N;
    vector<ll> data(N);
    rep0(i,N){cin>>data.at(i);}
    rep0(i,N){
        if(data.at(i)==i+1){
            
                
                ll s=data.at(i);
          if(i==N-1){data[i]=data[i-1];
                    data[i-1]=s;
                    }
          else{data.at(i)=data[i+1];
              data[i+1]=s;
              }
          
                
                cnt++;

            
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 1024
n, x0 = map(int, input().split())
x = list(map(int , input().split()))
x.append(x0)
y = [0] * n
for i in range(n):
    y[i] = x[i+1] - x[i]

if len(y) == 1:
    print(abs(y[0]))
    exit()

import fractions
d = fractions.gcd(y[0], y[1])
for xi in y:
    d = fractions.gcd(d, xi)
print(abs(d))


Measured memory_bytes: 14224
use proconio::input;

const MOD: i64 = 1000000007;

fn main() {
    input! {
        n: i64,
        k: i64,
    }

    let mut small_sum: i64 = 0;
    let mut large_sum: i64 = 0;

    for i in 0..k {
        small_sum += i;
        small_sum %= MOD;
        if small_sum < 0 {
            small_sum += MOD;
        }

        large_sum += n - i;
        large_sum %= MOD;
        if large_sum < 0 {
            large_sum += MOD;
        }
    }

    let mut ans: i64 = 0;
    for take in k..=(n + 1) {
        // dbg!(take, large_sum);
        ans += large_sum - small_sum + 1;
        ans %= MOD;
        if ans < 0 {
            ans += MOD;
        }

        small_sum += take;
        small_sum %= MOD;
        if small_sum < 0 {
            small_sum += MOD;
        }

        large_sum += n - take;
        large_sum %= MOD;
        if large_sum < 0 {
            large_sum += MOD;
        }

    }

    println!("{}", ans);
}



Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, s, x, y, z, count;
  cin >> k >> s;
  
  count = 0;
  
  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      int z = s - x - y;
      if (z >= 0 && z <= k) {
        ++count;
      }
    }
  }
          
  cout << count << endl;
}

Measured memory_bytes: 256
// abc154_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)
#define CHAR2INT(c) (c - '0')

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

ll dp[102][4][2] = {0};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string N;
    cin >> N;
    int K;
    cin >> K;

    dp[0][0][0] = 1;
    REP(i, N.size()){
        REP(j, K+1){
            REP(k, 2){
                int n = k ? 9 : CHAR2INT(N[i]);
                REP(d, n+1){
                    if (d == 0){
                        dp[i+1][j][k || (d!=n)] += dp[i][j][k];
                    } else {
                        if (j+1 < 4){
                            dp[i+1][j+1][k || (d!=n)] += dp[i][j][k];
                        }
                    }
//                    dp[i+1][(j+d)%D][k||(d!=n)] += dp[i][j][k] % MOD;
                }
            }
        }
    }
    print(dp[N.size()][K][0] + dp[N.size()][K][1]);

    int n = N.size();

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int n,m, i, j, k, l,o,p,q;
	int b[4][3][10] = {0};
	cin >> n;
	i = 1;
	o = 1;p = 1;q = 1;
	while (i<= n) {
		cin >> j >> k >> l >> m;
			b[j-1][k-1][l-1]= b[j - 1][k - 1][l - 1] +m;
		i++;
	}
	while (o <= 3) { 
		while (p <= 3) { 
			while (q <= 10) {
				printf(" %d", b[o-1][p-1][q-1]);
				q++; 
			}
			printf("\n");
			p++;
			q = 1;
		}
		printf("####################\n");
		o++;p = 1;
	}while (p <= 3) {
		while (q <= 10) {
			printf(" %d", b[3][p - 1][q - 1]);
			q++;
		}
		printf("\n");
		p++;
		q = 1;
	}
	return 0;
}


Measured memory_bytes: 3160
n = int(input())
p = list(map(int, input().split()))

count = 0

for i in range(0, n-2):
    if p[i] < p[i+1] and p[i+1] < p[i+2]:
        count += 1
    elif p[i] > p[i+1] and p[i+1] > p[i+2]:
        count += 1

print(count)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

int main() {
  
  int N, C;
  while(cin >> N >> C && N && C) {
    int panel[N]; memset(panel, 0, sizeof panel);
    rep(i, N) rep(j, 16) {
      int x; cin >> x;
      if(x) { panel[i] += 1<<j; }
    }
    
    int jubi[C]; memset(jubi, 0, sizeof jubi);
    rep(i, C) rep(j, 16) {
      int x; cin >> x;
      if(x) { jubi[i] += 1<<j; }
    }
    
    int dp[2][1<<16];
    memset(dp, -1, sizeof dp);
    dp[0][0] = 0;
    
    int const mask = (1<<16)-1;
    rep(i, N) rep(S, 1<<16) {
      if(dp[i&1][S] == -1) continue;
      dp[(i+1)&1][panel[i]|S] = max(dp[(i+1)&1][panel[i]|S], dp[i&1][S]);
      rep(j, C) {
        int nS = (panel[i]|S)&(mask^jubi[j]);
        int score = __builtin_popcount(panel[i]|S) - __builtin_popcount(nS);
        dp[(i+1)&1][nS] = max(dp[(i+1)&1][nS], dp[i&1][S] + score);
      }
    }
    cout << *max_element(dp[N&1], dp[N&1]+(1<<16)) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1684
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;


int main() {

	int start;
	int size;
	int getval;
	int ans;


	cin >> size;

	cin >> start;
	cin >> getval;

	ans = getval - start;
	if (getval < start)start = getval;


	for (int i = 2; i < size; i++) {
		cin >> getval;
		if (ans < getval - start)ans = getval - start;

		if (getval < start)start = getval;

	}

	printf("%d\n", ans);



	//system("pause");
	return 0;
}


Measured memory_bytes: 3208
use std::io;


fn main() {
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;

int N;
vector<vector<int>> G;
unordered_map<int, unordered_map<int, int>> memo;

int count(int p, int u) {
  if (memo[p][u] != 0) return memo[p][u];
  if (memo[u][p] != 0) return N - memo[u][p];

  int res = 1;
  for (int v : G[u]) {
    if (v == p) continue;
    res += count(u, v);
  }
  return memo[p][u] = res;
}

int main() {
  cin >> N;
  G.resize(N);
  rep(i, N - 1) {
    int A, B;
    cin >> A >> B;
    --A, --B;
    G[A].push_back(B);
    G[B].push_back(A);
  }

  ModInt ans = (ModInt(2).pow(N - 1) - 1) * N;
  rep(u, N) {
    for (int v : G[u]) {
      ans -= ModInt(2).pow(count(u, v)) - 1;
    }
  }
  ans /= ModInt(2).pow(N);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 57032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1e9

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

    int A, B, K;
    cin >> A >> B >> K;

    while(K > 0) {
        if (A%2 != 0) {
            A--;
        }
        B += A/2;
        A /= 2;
        K--;
        if (K <= 0) break;

        if (B%2 != 0) {
            B--;
        }
        A += B/2;
        B /= 2;
        K--;
    }
    cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

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

        List<Integer> x = IntStream.range(0, m)
                .mapToObj(i -> scanner.nextInt())
                .sorted()
                .collect(Collectors.toList());
        System.out.println(IntStream.range(0, x.size() - 1)
                .map(i -> x.get(i + 1) - x.get(i))
                .sorted()
                .limit(Math.max(0, m - n))
                .sum());
    }
}

Measured memory_bytes: 62092
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,l,a[500],sum;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

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

   int mn=10000000,ans=sum;

   for(int i=1;i<=n;i++){
      int cur = sum-a[i];
      if( abs( sum-cur )<mn ){
         mn = abs(sum-cur);
         ans = cur;
      }
   }

   cout << ans << endl;


return 0;
}
///....



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;

int main(){
    int N,M;cin>>N>>M;
    vector<vector<int>> s(M);
    vi p(M);
    REP(i, M){
        int k;cin>>k;
        REP(j, k){
            int tmp;cin>>tmp;
            s[i].push_back(tmp-1);
        }
    }
    REP(i, M){
        cin >> p[i];
    }

    int ans = 0;
    vi sign(N);
    REP(i, pow(2, N)){
        bool flag = true;
        REP(j, M){
            int sum = 0;
            REP(k, s[j].size()){
                sum += sign[s[j][k]];
            }
            if(sum%2!=p[j]) flag = false;
        }
        if(flag) ans++;

        sign[0]++;
        bool curi = sign[0] == 2;
        FOR(j, 1, N){
            if(curi){
                sign[j]++;
                sign[j-1]=0;
            }
            curi = sign[j] == 2;
        }
        
    }

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

Measured memory_bytes: 384
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

l = [0]*(n+1)
r = [0]*(n+1)

for i in range(n):
    l[i+1] = gcd(l[i], a[i])
    r[n-i-1] = gcd(r[n-i], a[n-i-1])

m = [0]*n

for i in range(n):
    m[i] = gcd(l[i], r[i+1])

print(max(m))

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

string s,t;

int main(){
	cin>>s>>t;
	int res=0;
	for(int i=0;i<3;i++) if(s[i]==t[i]) res++;
	cout<<res<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n: usize,
   }

   let f = 55555;
   let mut is_prime = vec![true; f * 5];
   let mut ans = vec![];

   is_prime[0] = false;
   is_prime[1] = false;
   for i in 2..f {
      if !is_prime[i] {
         continue;
      }
      if i % 5 == 1 {
         ans.push(i);
      }
      let mut j = 2;
      while i * j < f * 5 {
         is_prime[i * j] = false;
         j += 1;
      }
   }
   for i in 0..n {
      print!("{} ", ans[i]);
   }
}


Measured memory_bytes: 2252
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b = map(int, readline().split())
if a % 3 == 0 or b % 3 == 0 or(a + b) % 3 == 0:
    print('Possible')
else:
    print('Impossible')

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> A(M), B(M);
  std::vector<std::vector<int>> from(N);
  rep(i, M) {
    std::cin >> A[i] >> B[i];
    --A[i]; --B[i];
    from[A[i]].push_back(B[i]);
    from[B[i]].push_back(A[i]);
  }

  std::vector<int> prev(N, -1);
  prev[0] = 0;
  std::queue<int> q;
  q.push(0);
  while(! q.empty()) {
    int pos = q.front(); q.pop();
    for(int next : from[pos]) {
      if(next == prev[pos] || prev[next] >= 0) continue;
      prev[next] = pos;
      q.push(next);
    }
  }

  std::cout << "Yes" << '\n';
  for(int i = 1; i < N; ++i) {
    std::cout << prev[i] + 1 << '\n';
  }
}


Measured memory_bytes: 11748
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 109;
ll i,n,m,g,a;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,0,n){
        cin>>a;
        g = __gcd(g,llabs(a - m));
    }
    cout<<g;
    return 0;
}

Measured memory_bytes: 256
#define DEBUG 0
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2019/9/1 20:49:44
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a)
  {
    mint b{a};
    return *this *= b.power(MOD - 2);
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
class combination
{
public:
  vector<mint> inv, fact, factinv;
  static int MAX_SIZE;
  combination() : inv(MAX_SIZE), fact(MAX_SIZE), factinv(MAX_SIZE)
  {
    inv[1] = 1;
    for (auto i = 2; i < MAX_SIZE; i++)
    {
      inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
    }
    fact[0] = factinv[0] = 1;
    for (auto i = 1; i < MAX_SIZE; i++)
    {
      fact[i] = mint(i) * fact[i - 1];
      factinv[i] = inv[i] * factinv[i - 1];
    }
  }
  mint operator()(int n, int k)
  {
    if (n >= 0 && k >= 0 && n - k >= 0)
    {
      return fact[n] * factinv[k] * factinv[n - k];
    }
    return 0;
  }
};
int combination::MAX_SIZE = 3000010;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// constexpr double epsilon = 1e-10;
// constexpr ll infty = 1000000000000000LL;
// constexpr int dx[4] = {1, 0, -1, 0};
// constexpr int dy[4] = {0, 1, 0, -1};
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}

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

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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

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

ll dp[210000][4];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    rep(i,S.size()){
        rep(j,4){
            if (S[i] != '?') add(dp[i+1][j], dp[i][j]);
            else add(dp[i+1][j], dp[i][j] * 3 % MOD);
        }
        if (S[i] == 'A' || S[i] == '?') add(dp[i+1][1], dp[i][0]);
        if (S[i] == 'B' || S[i] == '?') add(dp[i+1][2], dp[i][1]);
        if (S[i] == 'C' || S[i] == '?') add(dp[i+1][3], dp[i][2]);
    }
    cout << dp[S.size()][3] << endl;
}

Measured memory_bytes: 6992
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        String planes = "";
        int row = 0;
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
            String str = scan.next();
            planes += str;
            if(row++ > 6){
                row = 0;
                if(planes.matches(".*1111.*"))System.out.println("C");
                else if(planes.matches(".*110000011.*"))System.out.println("G");
                else if(planes.matches(".*1100000011.*"))System.out.println("A");
                else if(planes.matches(".*11000000011.*"))System.out.println("E");
                else if(planes.matches(".*1000000110000001.*"))System.out.println("D");
                else if(planes.matches(".*100000001100000001.*"))System.out.println("F");
                else if(planes.matches(".*1000000010000000100000001.*"))System.out.println("B");
                planes = "";
            }
        }
    }
}



Measured memory_bytes: 29824
Pat=[1]
All=[1]
for i in range(51):
    Pat.append(Pat[i]*2+1)
    All.append(All[i]*2+3)

N,X=map(int,input().split())

def saiki(N,X):
    if N==0:
        if X<=0:
            return 0
        else:
            return 1
    elif X<=All[N-1]+1:
        return saiki(N-1,X-1)
    elif X<=All[N]-1:
        return Pat[N-1]+1+saiki(N-1,X-2-All[N-1])
    else:
        return Pat[N]
        
print(saiki(N,X))

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

int main( )
{
    int i, j, k, n;
    int s = 0, mx = 0;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> j;
        mx = max(mx, j);
        s += j;
    }
    s -= mx;
    if (mx < s) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


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

vector<vector<pair<int, int>>> g;
long d[2][111111], e[2][111111];
int c[111111];
tuple<int, int, int> h[222222];
int main() {
    int n, m, s, t, p = 1e9 + 7;
    cin >> n >> m >> s >> t;
    g.resize(n + 1);
    for(int i = 0; i < m; i++) {
        int u, v, d;
        cin >> u >> v >> d;
        h[i] = {u, v, d};
        g[u].emplace_back(v, d);
        g[v].emplace_back(u, d);
    }
    for(int j = 0; j < 2; j++) {
        priority_queue<pair<long, int>, vector<pair<long, int>>, greater<>> q;
        fill(d[j], d[j] + n + 1, 1e18);
        fill(c, c + n + 1, 0);
        q.emplace(d[j][s] = 0, s);
        e[j][s] = 1;
        while(!q.empty()) {
            int u = q.top().second;
            q.pop();
            if(c[u])
                continue;
            c[u] = 1;
            for(auto [v, i] : g[u]) {
                auto l = d[j][u] + i;
                if(d[j][v] < l)
                    continue;
                if(d[j][v] > l) {
                    e[j][v] = 0;
                    d[j][v] = l;
                    q.emplace(d[j][v], v);
                }
                (e[j][v] += e[j][u]) %= p;
            }
        }
        swap(s, t);
    }
    auto r = e[0][t] * e[0][t] % p;
    for(int i = 1; i <= n; i++) {
        auto x = d[0][i];
        if(x == d[1][i] && x + x == d[0][t]) {
            auto a = e[0][i] * e[1][i] % p;
            (r -= a * (a - p)) %= p;
        }
    }
    for(int i = 0; i < m; i++) {
        auto [u, v, l] = h[i];
        for(int j = 0; j < 2; j++) {
            swap(u, v);
            auto x = d[0][u], y = d[1][v], z = d[0][t];
            if(x + l + y == z && x + x < z && y + y < z) {
                auto a = e[0][u] * e[1][v] % p;
                (r -= a * (a - p)) %= p;
            }
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 20992
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
const LL inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;

int n,m;
LL dis[maxn];
struct Node{
	int u,v,w;
}t[maxn];

bool cmp(const Node &x,const Node &y){
	if(x.u==y.u) return x.v<=y.v;
	return x.u<y.u;
}

struct segment_tree{
#define lson (o<<1)
#define rson (o<<1|1)
	LL minv[4*maxn];
	inline void build(int o,int l,int r){
		if(l==r){
			minv[o]=inf;
			return;
		}
		int mid=(l+r)>>1;
		build(lson,l,mid);build(rson,mid+1,r);
		minv[o]=min(minv[lson],minv[rson]);
	}
	inline LL query(int o,int l,int r,int q){
		if(l==r) return minv[o];
		int mid=(l+r)>>1;
		minv[lson]=min(minv[lson],minv[o]);
		minv[rson]=min(minv[rson],minv[o]);
		if(q<=mid) return query(lson,l,mid,q);
		else return query(rson,mid+1,r,q);
	}
	inline void add(int o,int l,int r,int ql,int qr,LL v){
		if(ql<=l&&qr>=r){
			minv[o]=min(v,minv[o]);
			return;
		}
		int mid=(l+r)>>1;
		if(ql<=mid) add(lson,l,mid,ql,qr,v);
		if(qr>mid) add(rson,mid+1,r,ql,qr,v);
	}
}tree;

int main(){
	//freopen("test.txt","r",stdin);
	
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) 
		scanf("%d%d%d",&t[i].u,&t[i].v,&t[i].w);
	sort(t+1,t+m+1,cmp);
	tree.build(1,1,n);
	tree.add(1,1,n,1,1,0);
//	for(int i=1;i<=n;i++) cerr<<i<<" "<<tree.query(1,1,n,i)<<endl;
	for(int i=1;i<=m;i++){
		int u=t[i].u;
		LL num=tree.query(1,1,n,u);
		tree.add(1,1,n,u+1,t[i].v,t[i].w+num);
//		cerr<<u<<" "<<num<<" "<<t[i].w<<endl;
	}
	LL num=tree.query(1,1,n,n);
	if(num==inf) puts("-1");
	else cout<<num<<endl;
		
	return 0;
} 

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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  for (int i = 0; i < M; i++) {
    cin >> y[i];
  }
  sort(y.begin(), y.end());
  for (int i = X + 1; i <= Y; i++) {
    bool flag = true;
    for (int j = 0; j < N; j++) {
      if (i <= x[j]) {
        flag = false;
      }
    }
    for (int j = 0; j < M; j++) {
      if (y[j] < i) {
        flag = false;
      }
    }
    if (flag) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}

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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846

    void solve(){
        int n;
        cin>>n;
        vector<int>a(n+1,0);
        for(int i=1;i<=n;i++){
            for(int j=0;j<=n;j+=i)
                a[j]++;
        }
        ll total=0;
        for(ll i=1;i<=n;i++)
            total+=(i*(ll)a[i]);
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 42252
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long
 
#define pn          printf("\n")
#define nl          cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")
 
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
 
#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup erase(unique(V.begin(),V.end()),V.end())
 
#define TC int test; cin>>test; test++; while(--test)
 
#define Inf     1000000000000000
#define mod     1000000007
#define M1      1000000007
#define M2      1000000009
using namespace std;
 
lli Power(lli a,lli b)
{
    lli result=1;
 
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }
 
        b=b>>1;
        a=(a*a)%mod;
    }
 
 return result;
}
 
int main()
{
    opt;
 
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli x,y;
    cin>>x>>y;
    
    vlli V1(7),V2(4);
    
    if(x==2 or y==2)
    {
        cout<<"No";
        exit(0);
    }
    
    V1[0]=1;
    V1[1]=3;
    V1[2]=5;
    V1[3]=7;
    V1[4]=8;
    V1[5]=10;
    V1[6]=12;
   
   V2[0]=4;
   V2[1]=6;
   V2[2]=9;
   V2[3]=11;
   
   if(binary_search(V1.begin(),V1.end(),x))
   {
       if(binary_search(V1.begin(),V1.end(),y))
       {
            cout<<"Yes";   
       }
       else
       {
           cout<<"No";
       }
   }
   else
   {
       if(binary_search(V1.begin(),V1.end(),y))
       {
           cout<<"No";
       }
       else
       {
           cout<<"Yes";
       }
   }
 
 
 
 return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (unless)
import Data.Vector.Unboxed.Mutable (IOVector, STVector)
import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad.ST

main :: IO ()
main = do
  [n, p] <- map read <$> words <$> getLine
  unless (n == 0 && p == 0) $ do
    print $ solve n p
    main

solve :: Int -> Int -> Int
solve n p = runST $ do
  stn <- VM.replicate n 0
  step 0 p stn
  where step :: Int -> Int -> STVector s Int -> ST s Int
        step trn bwl stn = do
          if bwl > 1 then do
            modify stn (+1) trn
            step ((trn+1) `mod` n) (bwl-1) stn
          else if bwl == 1 then do
            x <- VM.read stn trn
            if x+1 == p then do
              return trn
            else do
              VM.write stn trn (x+1)
              step ((trn+1) `mod` n) 0 stn
          else do
            x <- VM.read stn trn
            VM.write stn trn 0
            step ((trn+1) `mod` n) x stn

modify :: STVector s Int -> (Int->Int) -> Int -> ST s ()
modify v f i = do
  x <- VM.read v i
  VM.write v i (f x)



Measured memory_bytes: 4560
#include<iostream>
#include<string>
using namespace std;
int main(){
  string moziretu;
  cin>>moziretu;
  for(int i = 0; i < moziretu.size(); i++){
    int s=-1;
    s = moziretu.find('C',i);
    if(s!=-1){
      int t = moziretu.find('F',s);
      if(t - s >= 1 && t - s <= 100){
	cout<<"Yes"<<endl;
	return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int a[N + 1];
  a[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += max(0, a[i + 1] - a[i]);
  }
  cout << sum << endl;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  string S; // size N
  cin >> S;
  int ans = 0;
  rep(i,N-1) if(S.at(i) == S.at(i + 1))ans++;
  cout << min(ans + K * 2, N -1 ) << endl;
}


Measured memory_bytes: 512
/**
 *      purpose : ABC 115 C
 *      author  : kyomukyomupurin
 *      created : 2018-12-08 21:15:40
**/

#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

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

    int n, k; cin >> n >> k;
    int h[n];
    rep(i, n) cin >> h[i];
    sort(h, h + n);

    int mm = 1e9 + 334;

    for (int i = 0; i < n - k + 1; ++i){
        mm = min(mm, h[k + i - 1] - h[i]);
    }
    print(mm);
    
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  int  X,N,A,B;


   scanf("%d%d%d",&N,&A,&B) ;
   X=N*A;

    if(X>B)
    {
        printf("%d",B);
    }

    else {

        printf("%d",X);
    }



return 0;

}


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

occ = {}
for i in range(n):
    if a[i] not in occ:
        occ[a[i]] = 0
    occ[a[i]] += 1

res = 0
for x in occ:
    if (occ[x] < x):
        res += occ[x]
    else:
        res += occ[x] - x

print(res)


Measured memory_bytes: 68264
# -*- coding: utf-8 -*-
n = int(input())
play_list = []
for _ in range(n):
    title, time = input().split()
    play_list.append((title, int(time)))
x = input()

sleep = 0
is_sleep = False
for title, time in play_list:
    if is_sleep:
        sleep += time
    else:
        is_sleep = title == x

print(sleep)


Measured memory_bytes: 3060
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	long a=sc.nextLong(),b;
    String op=sc.next();
    b=sc.nextLong();
    if(op.equals("+")){
      System.out.println(a+b);
    }else{System.out.println(a-b);}
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int n,m;cin>>n>>m;int lans = 0, rans = INF;
  rep(i,m){
    int l,r;cin>>l>>r;
    lans = max(l, lans);
    rans = min(r,rans);
  }
  cout << max((int)0,rans - lans +1) << endl;
}


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

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
}

int main() {
    fast();
    ll n;  cin >>n;
    ll arr[n][3];
    for(ll i=0;i<n;i++){
        cin >>arr[i][0] >>arr[i][1] >>arr[i][2];
    }
    ll dp[n][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    
    for(ll i=1;i<n;i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2])+arr[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2])+arr[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1])+arr[i][2];
    }
    
    ll answer = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    
    cout<<answer;
    
    return 0;
}


Measured memory_bytes: 8328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int K;
        int a,b,c;
        try (Scanner sc = new Scanner(System.in)) {
            K = sc.nextInt();
        }
        a = b = c =  K;
        long result = 0;
        for (int i = 1; i <= a; i++) {
            for (int j = 1; j <= b; j++) {
                for (int k = 1; k <= c; k++) {
                    long temp = gcd((long)i,(long)j);
                    temp = gcd(temp,(long)k);
                    result += temp;
                }
            }
        }
        System.out.println(result);
    }

    //最大公約数
    static long gcd(long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return (long) b;
    }
}


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

#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

#define MAX_N 20
#define MAX_Q 200

int lst_a[MAX_N + 5];
int lst_m[MAX_Q + 5];

bool solve(int i, int m, int n) {
  if (m == 0) return true;
  if (i >= n) return false;
  return solve(i + 1, m, n) || solve(i + 1, m - lst_a[i], n);
}

int main() {
  int n, q;
  cin >> n;
  rep(i, n) cin >> lst_a[i];
  cin >> q;
  rep(i, q) cin >> lst_m[i];

  rep(i, q) {
    if (solve(0, lst_m[i], n))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
from sys import stdin

input = stdin.readline


def p_a():
    n = int(input())
    print(((n + 1) // 2) / n)


def p_b():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    print(sum(map(lambda x: x >= k, h)))


if __name__ == '__main__':
    p_b()


Measured memory_bytes: 49904
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
ll n,m;
ll dp[100007];
vector<ll> adj[100007];
bool vis[100007]={0};

ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}
ll dfs(ll x)
{
	if(vis[x])
		return dp[x];
	vis[x]=1;
	ll ma=0;
	for(ll i=0; i<adj[x].size(); i++){
		ll v=adj[x][i];
		ma=max(ma,1+dfs(v));
	}
	return dp[x]=ma;
}

int main()
{
	fastio
	cin>>n>>m;
	lp(i,0,m-1)
	{
		ll u,v;
		cin>>u>>v;
		adj[u].PB(v);
	}
	ll ans=0;
	lp(i,1,n)
		ans=max(ans,dfs(i));
	cout<<ans<<endl;

	return 0;	
}


Measured memory_bytes: 8704
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int e = 0;
		int o = 0;
		for (int i = 1; i <= K; i++) {
			if (i%2==0) {
				e++;
			} else {
				o++;
			}
		}
		System.out.println(e*o);
	}
}


Measured memory_bytes: 21460