akhauriyash/Code-Regression huggingface dataset:
// ------------------------------------
// Date:2018/ 3/21
// Problem:A- Multiple Array a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

typedef pair< ll, ll > PL;

int main()
{
  CIN(N);
  vector< PL > a(N);
  REP(i, N) {
    LCIN(p, q);
    a[i] = make_pair(q - (p + q) % q, q);
  }
  
  ll ans = 0ll;
  ll bias = 0;
  RREP(i, N) {
    ll tmp;
    if (a[i].second == 1) {
      // OK(true);
      tmp = 0;
    } else if ((((a[i].first - bias) % a[i].second + a[i].second) % a[i].second) == 0) {
      // OK(false);
      tmp = 0;
    } else tmp = ((a[i].first - bias) % a[i].second + a[i].second) % a[i].second;
    ans += tmp;
    bias += tmp;
    // debug(ans);
    // debug(tmp);
  }

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



Measured memory_bytes: 1792
MOD = (10 ** 9) + 7

fact = [0] * 1100000
invfact = [0] * 1100000

fact[0] = 1
for i in range(1, 1100000):
    fact[i] = fact[i-1] * i % MOD

invfact[1100000 - 1] = pow(fact[1100000 - 1], MOD-2, MOD)

for i in range(1100000 - 1, 0, -1):
    invfact[i-1] = invfact[i] * i % MOD
    

def nCk(n, k):
    return fact[n] * invfact[k] * invfact[n-k] % MOD

def nPk(n, k):
    return fact[n] * invfact[n-k] % MOD

## kokokara fine

n, m = map(int, input().split())

ans = 0

for k in range(n+1):
    tmp = nCk(n, k) * nPk(m, k) * (nPk(m-k,n-k) ** 2) % MOD
    if k % 2 == 0:
        ans += tmp
    else:
        ans -= tmp
    ans %= MOD

print(ans)

Measured memory_bytes: 95788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,t;
    cin>>s;
    if(s=="Sunny")
    cout<<"Cloudy\n";
   if(s=="Cloudy")
   cout<<"Rainy\n";
  if(s=="Rainy")cout<<"Sunny\n";
  }

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		pr.println(Math.min(a + b, Math.min(b + c, c + a)));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
vector<int> G[100000];

int dfs(int x, int p) {
  int g = 0;
  for (int t : G[x]) {
    if (t == p) continue;
    g ^= dfs(t, x);
  }
  return g+1;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N-1) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].pb(y);
    G[y].pb(x);
  }
  int g = 0;
  for (int t : G[0]) {
    g ^= dfs(t, 0);
  }
  if (g == 0) cout << "Bob\n";
  else cout << "Alice\n";
  return 0;
}


Measured memory_bytes: 10368
import java.io.*;
  
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        int x = Integer.parseInt(input);
  
        System.out.println((int) Math.pow(x, 3));
    }
}

Measured memory_bytes: 24440
#include<bits/stdc++.h>
using namespace std;
string x;
multiset<string>s;
set<string>a;
multiset<string>ss;
int main()
{
    int n,m;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        cin>>x;
        s.insert(x);
        a.insert(x);
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++)
    {
        cin>>x;
        ss.insert(x);
    }
    int ans=0;
    for(set<string>::iterator it=a.begin();it!=a.end();it++)
    {
        int p=s.count(*it);
        int k=ss.count(*it);
        if(p>k)
            ans=max(ans,p-k);
    }
    if(ans<0)
        printf("0\n");
    else printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
int n;
struct Node{
  int p; //parent
  int l; //left-child
  int r; //right sibiling
};
struct Node T[MAX];
int depth(int u){
  int d=0;
  int tmp=T[u].p;
  while( tmp!=NIL ){ d++; tmp=T[tmp].p;}
  return d;
}
int height(int u){
  int l=NIL;
  int r=NIL;
  if( T[u].l!=NIL ) l=height(T[u].l);
  if( T[u].r!=NIL ) r=height(T[u].r);
  l++;
  r++;
  if( l>r ) return l;
  else return r;
}
int find_sibling(int u){
  int tmp=T[u].p;
  if( tmp!=NIL ){
    if( T[tmp].r==u ) return T[tmp].l;
    else return T[tmp].r;
  }
  return NIL;
}
int degree(int u){
  int d=0;
  if( T[u].l!=NIL )d++;
  if( T[u].r!=NIL )d++;
  return d;
}
void print(int u){
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u, T[u].p, find_sibling(u), degree(u), depth(u), height(u));
  if( T[u].p==NIL) printf("root\n");
  else if( T[u].l!=NIL || T[u].r!=NIL) printf("internal node\n");
  else printf("leaf\n");
}
int main(void){
  int i;
  int d;
  scanf("%d", &n);
  for ( i=0; i<n; i++ ) T[i].p=T[i].l=T[i].r=NIL;
  for ( i=0; i<n; i++ ){
    scanf("%d", &d);
    scanf("%d %d", &T[d].l, &T[d].r);
    T[T[d].l].p=T[T[d].r].p=d;
  }
  for ( i=0; i<n; i++ ) print(i);
  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
const int INF = 100000;
string a[]={"Sunny","Cloudy","Rainy"};
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<a[1];
    }
    else if(s=="Cloudy"){
        cout<<a[2];
    }
    else {
        cout<<a[0];
    }
}


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

    
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; 
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    const auto &pf = prime_factorize(N);
    long long res = 0;
    for (auto p : pf){
        for(int i = 1; ;i++){  
            if( i * (i+1) / 2 <= p.second && p.second < (i+1) * (i+2) / 2){
                res += i;
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}





Measured memory_bytes: 3524
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int
main(void){  
  ios_base::sync_with_stdio(false);
  int n, h, w;
  
  cin >> n >> h >> w;

  cout << (n-w+1)*(n-h+1) << endl;
  
  return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin >> l[i];
    }

    sort(l.begin(),l.end());

    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if(l[i]==l[j]){
                continue;
            }
            for(int k=j+1;k<n;k++){
                if(l[j]==l[k]){
                    continue;
                }
                if(l[i]+l[j]>l[k]){
                    ans ++;
                }
            }
        }
    }
    cout << ans << endl;
}


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

#define LLINF 1100000000000000000

using namespace std;

typedef long long ll;

int main()
{
  ll H, W;
  cin >> H >> W;

  ll h1 = H / 3;
  ll h2 = (H - h1) / 2;
  ll h3 = H - h1 - h2;
  ll ans1 = max({h1, h2, h3}) * W - min({h1, h2, h3}) * W;


  ll w1 = W / 3;
  ll w2 = (W - w1) / 2;
  ll w3 = W - w1 - w2;
  ll ans2 = max({w1, w2, w3}) * H - min({w1, w2, w3}) * H;

  ll ans3 = LLINF;
  //(W + 1) / 2 で2で割って切り上げ
  for (int i = 1; i <= (W + 1)/2; i++) {
    ll s1 = i * H;
    ll s2 = (W - i) * (H / 2);
    ll s3 = (W - i) * (H - H / 2);
    ans3 = min(max({s1, s2, s3}) - min({s1, s2, s3}), ans3);
  }

  ll ans4 = LLINF;
  //(W + 1) / 2 で2で割って切り上げ
  for (int i = 1; i <= (H + 1)/2; i++) {
    ll s1 = i * W;
    ll s2 = (H - i) * (W / 2);
    ll s3 = (H - i) * (W - W / 2);
    ans4 = min(max({s1, s2, s3}) - min({s1, s2, s3}), ans4);
  }

  cout << min({ans1, ans2, ans3, ans4}) << endl;

  return 0;
}


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

int main() {
  ll c[10],d[10];
  c[0]=d[0]=1;
  c[1]=9;
  d[1]=10;
  for(int i=2; i<10; i++) {
    c[i]=c[i-1]*10;
    d[i]=c[i]*i+d[i-1];
  }
  ll n,k;
  while(cin >> n >> k && n) {
    ll i;
    for(i=9; i>=0; i--) if(n>=d[i]) break;
    n-=d[i];
    ll r=pow(10,i);
    ll x=n/(r*(i+1)),y=n%(r*(i+1));
    ll z=y%(i+1);y/=i+1;
    x++;
    string s="";
    for(int j=0; j<100; j++) {
      stringstream ss;
      string t;
      ss << r*x+y+j;
      ss >> t;
      s+=t;
    }
    for(int j=0; j<k; j++) cout << s[j+z];
    cout << endl;
  }
  return 0;
}


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

void init() {

}

long long f(long long b, long long n) {
	if (b > n) return n;
	return f(b, n/b) + n%b;
}

void solve() {
	long long n, s; scanf("%lld %lld", &n, &s);
	if (n == s) {
		printf("%lld", n+1);
		return;
	}
	if (n < s) {
		printf("-1");
		return;
	}
	vector<long long> divs;
	divs.push_back(n-s);
	for (long long i = 2; i*i <= n; ++i) {
		if ((n-s)%i == 0) {
			divs.push_back((n-s)/i);
		}
		if (f(i, n) == s) {
			printf("%lld", i);
			return;
		}
	}
	divs.push_back(1);
	for (int i = (int)divs.size()-1; i >= 0; --i) {
		if (f(divs[i]+1, n) == s) {
			printf("%lld", divs[i]+1);
			return;
		}
	}
	printf("-1");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

const int N = 2e5 + 5;
const ll INF = 1e18L + 5;

int t[4*N] = {0}, lazy[4*N] = {0};

void push(int node){
    for(auto child: {2*node, 2*node + 1}){
        t[child] += lazy[node];
        lazy[child] += lazy[node];
    }
    lazy[node] = 0;
}

void update(int node, int tl, int tr, int l, int r, int add){
    if(l > r) return;
    if(tl == l && tr == r){
        t[node] += add;
        lazy[node] += add;
    } else {
        push(node);
        int tm = (tl + tr)>>1;
        update(2*node, tl, tm, l, min(r, tm), add);
        update(2*node+1, tm+1, tr, max(l, tm+1), r, add);
        t[node] = min(t[2*node], t[2*node+1]);
    }
}

int query(int node, int tl, int tr, int l, int r){
    if(l > r) return 0;
    if(tl == l && tr == r) return t[node];
    push(node);
    int tm = (tl + tr)>>1;
    return min(query(2*node, tl, tm, l, min(r, tm)),
               query(2*node+1, tm+1, tr, max(l, tm+1), r));
}


void solve(){
    ll n, m, l, r, x;
    cin>>n>>m;

    ll tot = 0;
    vector<pll> en[n+1];
    for(int i=0; i<m; i++){
        cin>>l>>r>>x;
        tot += x;
        en[r].push_back({l, x});
    }

    ll best = tot;

    for(int i=1; i <= n+1; i++){
        /// best value till now for putting 1 here
        for(auto p: en[i - 1]){
            l = p.first;
            x = p.second;
            update(1, 0, N - 1, 0, l - 1, x);
        }

        best = query(1, 0, N - 1, 0, i - 1);
        update(1, 0, N - 1, i, i, best);
    }

    cout<<tot - best;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

int main()
{
  int H, W;

  while(cin >> H >> W, H || W){
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if((i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0))
          cout << "#";
        else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;

}

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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

string s;
cin >> s;
int count=0;
char temp=s[0];
for(int i=0;i<n;i++){

while(true){
i++;
if(i==n){
count++;
break;
}
if(temp==s[i]){
}else{
temp=s[i];
count++;
}

}

}

cout << count;

}


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

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

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

    int flag = 0;
    for(int i = 0; i < N; i++){
        if(A[i] % 2 == 0){
            if(A[i] % 3 != 0 && A[i] % 5 != 0){
                flag = -1;
                break;
            }
        }
    }

    if(flag == 0) cout << "APPROVED" << endl;
    if(flag == -1) cout << "DENIED" << endl;

}

Measured memory_bytes: 256
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    ll n;
    cin>>n;

    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
    {
        ll tot=0;
        for(ll j=1;j<=n;j++)
        {
            tot+=__gcd(i,j);
        }
        v[i]=tot;
    }

    ll ans=0;

    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            ll val=__gcd(i,j);
            ans+=v[val];
        }
    }
    cout<<ans<<"\n";
    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 3848
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//ABC139 B
int main() {
	int a, b;
	cin >> a >> b;

	int num = 1;
	int ans = 0;
	while (num < b) {
		num--;
		num += a;
		ans += 1;
	}
	cout << ans << endl;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll m,n,k,t=0,an=0,bn=0,ans=0,ta=0,al,bl;
  vector<ll> a,b;
  cin >>n>>m>>k;
  rep(i,n){
    ll x;
    cin >>x;
    if(t+x<=k&&a.size()==i){
      a.push_back(x);
      t+=x;
    }
  }
  al=k-t;
  t=0;
  rep(i,m){
    ll x;
    cin >>x;
    if(t+x<=k&&b.size()==i){
      b.push_back(x);
      t+=x;
    }
  }
  bl=k-t;
  if(a.size()<b.size()) {
    swap(a,b);
    swap(al,bl);
  }
  ans=a.size();
  an=ans-1;
  while(b.size()>0&&bn<b.size()&&al>=b[bn]){
    al-=b[bn];
    bn++;
    ans++;
  }
  //cout <<ans;
  ta=ans;
  while(an>=0){
    al+=a[an];an--;ta--;
    while(bn<b.size()&&al>b[bn]){
      al-=b[bn];bn++;ta++;
      ans=max(ans,ta);
      if(bn==b.size())break;
    }
    if(bn==b.size())break;
  }
  cout <<ans;
}

Measured memory_bytes: 7904
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
				scanner.useDelimiter(",|\\n");
		int x,y,plotSize;
		int paper[][] = new int[14][14];
		int zeroCellNum = 0;
		int mostDark = 0;
		while(scanner.hasNext()){
			x = 2 + scanner.nextInt();
			y = 2 + scanner.nextInt();
			plotSize = scanner.nextInt();
			paper[x][y]++;
			paper[x+1][y]++;
			paper[x-1][y]++;
			paper[x][y+1]++;
			paper[x][y-1]++;
			if(plotSize >= 2){
				paper[x+1][y+1]++;
				paper[x+1][y-1]++;
				paper[x-1][y+1]++;
				paper[x-1][y-1]++;
			}
			if(plotSize == 3){
				paper[x+2][y]++;
				paper[x-2][y]++;
				paper[x][y+2]++;
				paper[x][y-2]++;
			}
		}
		for(int i=2; i<12; i++){
			for(int j=2; j<12; j++){
				if(paper[i][j] == 0){
					zeroCellNum++;
				}
				if(paper[i][j] > mostDark){
					mostDark = paper[i][j];
				}
			}
		}
		System.out.println(zeroCellNum);
		System.out.println(mostDark);
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> tmp(n);
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      tmp.at(a-1) = 1;
    }
  }
  int cnt = 0;
  rep(i, n) {
    if(tmp.at(i) == 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int rnd(int n){
    return (n>255)?255:(n<0)?0:n;
}

int main(void){
    int n,m;
    while(cin>>n>>m,n){
        vector<vector<int>> dp(2,vector<int>(256,999999999));
        vector<int> c_data(m),x(n);
        for(int i=0;i<m;i++) cin>>c_data[i];
        for(int i=0;i<n;i++) cin>>x[i];
        dp[0][128]=0;
        for(int i=1;i<n+1;i++){
            dp[i%2]=vector<int>(256,999999999);
            for(int j=0;j<256;j++){
                if(dp[(i+1)%2][j]==999999999) continue;
                for(auto c:c_data){
                    dp[i%2][rnd(j+c)]=min(dp[i%2][rnd(j+c)],
                                        dp[(i+1)%2][j]+(rnd(j+c)-x[i-1])*(rnd(j+c)-x[i-1]));
                }
            }
        }
        cout<<*min_element(dp[n%2].begin(),dp[n%2].end())<<endl;
    }
}


Measured memory_bytes: 3132
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
signed main(void)
{
	int a[4];
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+3+1);
	if(a[1]==a[2]&&a[2]!=a[3])
	{
		puts("Yes");
		return 0;
	}
	if(a[2]==a[3]&&a[1]!=a[2])
	{
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}



Measured memory_bytes: 384
n, m, l = map(int, input().split())
a = [None] * n
b = [None] * m
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(m):
    b[i] = list(map(int, input().split()))
c = [[0] * l for _ in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for row in c:
    print(' '.join(map(str, row)))



Measured memory_bytes: 6896
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
 
const int N = 2e5 + 5;
const int mod = 1e9+7;
const ll INF = (ll)1e18;

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

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

struct MAT{
    int r, c;
    vector< vector<int> > v;

    MAT(int _r, int _c) : r(_r), c(_c){
        v.resize(r, vector<int>(c, 0));
        if(r == c)
            for(int j = 0; j < r; j++) v[j][j] = 1;
    }

    MAT mult(const MAT& lhs, const MAT& rhs){
        MAT ans(lhs.r, rhs.c);
        for(int j = 0; j < lhs.r; j++){
            for(int k = 0; k < rhs.c; k++){
                int &cur = ans.v[j][k];
                cur = 0;
                for(int i = 0; i < lhs.c; i++)
                    cur = add(cur, mul(lhs.v[j][i], rhs.v[i][k])); 
            }
        }
        return ans;
    }

    void print(){
        for(int j = 0; j < r; j++){
            for(int k = 0; k < c; k++) cout << v[j][k] << " ";
            cout << endl;
        }
        cout << endl;
    }
};

MAT foo(MAT a, ll b){
    MAT ans(a.r, a.c);
    while(b){
        if(b&1) ans = ans.mult(ans, a);
        a = a.mult(a, a);
        b /= 2;
        // a.print();
    }
    return ans;
}

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
 
    ll n, K;
    cin >> n >> K;
    MAT init(n, n);
    for(int j = 0; j < n; j++)
        for(int k = 0; k < n; k++) cin >> init.v[j][k];

    MAT res = foo(init, K);
    int ans = 0;
    for(int j = 0; j < n; j++)
        for(int k = 0; k < n; k++) ans = add(ans, res.v[j][k]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
  }

  vector<ll> sum(n+1);
  sum[0] = 0;
  rep1(i,n){
    sum[i] = sum[i-1] + a[i-1];
  }

  rep(i,n+1){
    sum[i] = (sum[i] - i)%k;
  }
  
  ll res=0;  
  map<ll,ll> mp;
  rep(i,min(k-1,n+1)){
    if(mp.count(sum[i])==1){
      res += mp[sum[i]];    
    }
    mp[sum[i]]++;
  }

  for(ll j=k-1;j<=n;++j){
    if(mp.count(sum[j])==1){
      res += mp[sum[j]];
    }
    mp[sum[j]]++;
    mp[sum[j-k+1]]--;
  }
    
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 15872
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import Data.Bits

main = putStrLn . show . solve =<< parse

parse :: IO (Int, Int, Int, Int)
parse = (\[h, w, a, b] -> (h, w, a, b)) . map read . words <$> getLine

solve :: (Int, Int, Int, Int) -> Int
solve (h, w, a, b) = foldl add 0 $ map intrude [b .. w - 1] where
    fact = newFact $ h + w
    inv = newInv fact $ max h w
    ways x y = (fact ! (x + y)) `mul` (inv ! x) `mul` (inv ! y)
    intrude i = (ways (h - a - 1) i) `mul` (ways (a - 1) (w - i - 1))


newFact :: Int -> UArray Int Int
newFact n = runSTUArray $ do
    fact <- newArray_ (0, n) :: ST s (STUArray s Int Int)
    writeArray fact 0 1
    forM_ [1 .. n] $ \i -> do
        n <- readArray fact $ i - 1
        writeArray fact i $ mul n i
    return fact

newInv :: UArray Int Int -> Int -> UArray Int Int
newInv fact n = runSTUArray $ do
    inv <- newArray_ (0, n) :: ST s (STUArray s Int Int)
    writeArray inv 0 1
    writeArray inv 1 1
    writeArray inv n $ pow (fact ! n) (modulo - 2)
    forM_ [n - 1, n - 2 .. 2] $ \i -> do
        x <- readArray inv $ i + 1
        writeArray inv i $ mul x (i + 1)
    return inv

add :: Int -> Int -> Int
add n m = (n + m) `mod` modulo

add' :: Int -> Int -> Int
add' n m
    | n + m >= modulo = n + m - modulo
    | otherwise = n + m

mul :: Int -> Int -> Int
mul n m = mul' (n `mod` modulo) m 0
mul' n m res
    | m <= 0 = res
    | odd m = mul' (shiftL n 1 `add'` modulo) (shiftR m 1) (add res n)
    | otherwise = mul' (shiftL n 1 `add'` modulo) (shiftR m 1) res

pow :: Int -> Int -> Int
pow _ 0 = 1
pow n m
    | even m = mul x x
    | otherwise = mul n . pow n $ m - 1 where
          x = pow n $ shiftR m 1

modulo :: Int
modulo = 10 ^ 9 + 7


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi a(n),b(n);
		rep(i,n) cin>>a[i]>>b[i];

		if(a==b){
			cout<<0<<endl;
			continue;
		}

		ll sum=accumulate(all(a),0ll);
		ll last=INF;
		rep(i,n) if(a[i]>b[i])
			chmin(last,b[i]);
		cout<<sum-last<<endl;
	}
}


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

using namespace std;

using int64 = long long;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int main() {
  int N, M, S, T;
  cin >> N >> M >> S >> T;
  WeightedGraph< int64 > g(N), h(N);
  for(int i = 0; i < M; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
    h[a].emplace_back(b, d);
    h[b].emplace_back(a, d);
  }

  --S, --T;
  auto latte = dijkstra(g, S);
  auto malta = dijkstra(h, T);

  const int64 INF = 1LL << 60;
  int64 ret = INF;
  vector< int64 > cost(N);
  for(int i = N - 1; i >= 0; i--) {
    ret = min(ret, latte[i] + malta[i]);
    cost[i] = ret;
  }
  for(int i = 0; i < N; i++) {
    cout << 1000000000000000 - cost[i] << endl;
  }
}



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


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


int main() 
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, n - 2)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		long n, k;

		n = scan.nextLong();
		k = scan.nextLong();

		long min = n;

		if (k == 1) {
			System.out.println(0);
			return;
		}

		if (n == 0) {
			System.out.println(0);
			return;
		}

		while (true) {
			long sa = Math.abs(n - k);

			long amari = n % k;
			long tmp;

			if (amari >= sa) {
				tmp = sa;
			} else {
				tmp = amari;
			}

			n = tmp;

			if (min > tmp) {
				min = tmp;
			} else {
				System.out.println(min);
				return;
			}

			if (min == 0) {
				System.out.println(0);
				return;
			}
		}

	}

	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

using namespace std;

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

	int n;
	cin >> n;

	vector<pair<int, int> > a;
	a.emplace_back(0, 0);

	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;

		a.emplace_back(x, i);

	}

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

	vector<long long> ans;
	ans.resize(n);

	int cnt = 0;

	set<int> s;

	while(a.size() > 1) {
		++cnt;
		
		int h = a.back().first;
		int p = a.back().second;

		a.pop_back();

		s.emplace(p);

		ans[*s.begin()] += 1LL * cnt * (h - a.back().first);

	}

	for(auto x : ans) {
		cout << x << '\n';
	}

	return 0;

}

Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;

    sort(s.begin(),s.end());

    if (s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

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

  long last=0;
  long res=0;
  rep(i,n){
    long d;
    scanf("%ld", &d);
    if(d!=0) d+=last;
    res += d/2;
    last = d%2;
  }

  cout<<res<<endl;

  return 0;
}


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

# データ数の取込み
NN = int( input() )
total = 0
bitcoin = 380000.0
for ii in range( NN ) :
    money, currency_type = input().split()
    # print( ii, money, currency_type)
    if currency_type == "JPY" :
      total += int( money )
    elif currency_type == "BTC" :
      yen = float( money ) * bitcoin
      total += yen
else:
  print( total )


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

int mod = 1e9 + 7;

int main() {
    int N; cin >> N;
    vector<ll> cnt(N+1);
    for (int i = 2; i <= N; i++){
        int now = i;
        for (int j = 2; j*j <= i; j++){
            while(now % j == 0){
                now /= j;
                cnt[j]++;
            }
        }
        if(now != 1){
            cnt[now]++;
        }
    }

    ll ans = 1;
    for (int i = 2; i <= N; i++){
        ans *= cnt[i]+1;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

const int MOD = 1000 * 1000 * 1000 + 7;

int main(void) {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> s(n);
  std::vector<int> t(m);
  for (int i = 0; i < n; ++i) {
    std::cin >> s[i];
  }
  for (int i = 0; i < m; ++i) {
    std::cin >> t[i];
  }
  int sl = n + 1;
  int tl = m + 1;
  std::vector<int64_t> dp(sl * tl);

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      auto &now = dp[tl * i + j];
      auto &left = dp[tl * i + j - 1];
      auto &up = dp[tl * (i - 1) + j];
      auto &lu = dp[tl * (i - 1) + j - 1];

      now = (left + up) % MOD;
      if (s[i - 1] == t[j - 1])
        now = (now + 1) % MOD;
      else
        now = (now + MOD - lu) % MOD;
    }
  }

  std::cout << (dp[n * tl + m] + 1) % MOD << std::endl;
  return 0;
}


Measured memory_bytes: 31488
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;
#define EPS (1e-6)
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef pair<double,double> P;

bool isCross(P p1, P p2, P p3, P p4){
  double c = ((p1.first - p2.first) * (p3.second - p1.second) + (p1.second - p2.second) * (p1.first - p3.first)) * 
    ((p1.first - p2.first) * (p4.second - p1.second) + (p1.second - p2.second) * (p1.first - p4.first));
  if(c<=0.0)
    return true;
  return false;
}

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(3);

  int INF = 1000000;

  stack<int> rail;

  int a;
  while(cin>>a){
    if(a!=0){
      rail.push(a);
    }
    else{
      cout << rail.top() << endl;
      rail.pop();

    }
  }
  


  return 0;
}

Measured memory_bytes: 1200
/******************************************
*    AUTHOR:         julianferres         *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
const int INF = 2000000000;
#define MOD 1000000007
#define MAXN 200005

int main(){
    FIN;
    string s, p;
    cin >> s >> p;
    ll n = s.size(), m = p.size();

    vector<vi> dp(n + 1, vi(m + 1, 0));

    forn(i,n+1){
        forn(j,m+1){
            if(i==0 || j==0)
                dp[i][j] = 0;
            else if(s[i-1]==p[j-1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
        }
    }
    ll r = n, c = m, toWrite = dp[n][m];
    char ans[dp[n][m]];

    while (r > 0 && c> 0)
    {
        if(s[r-1] == p[c-1]){
            ans[--toWrite] = s[r - 1];
            c--, r--;
        }
        else if(dp[r-1][c]>dp[r][c-1])
            r--;
        else
            c--;
    }
    forn(i,dp[n][m])
        cout << ans[i];
    cout << endl;

    return 0;
}





Measured memory_bytes: 70784
def B():
    NMC = input().split()
    N = int(NMC[0])
    M = int(NMC[1])
    C = int(NMC[2])
    B = [int(i) for i in input().split()]
    A = []
    for i in range(N):
        A.append([int(a) for a in input().split()])

    acc = 0
    for i in range(N):
        clear = False
        eq = 0

        for j in range(M):
            eq += B[j] * A[i][j]
        eq += C
        if eq > 0:
            acc += 1 

    print (acc)

if __name__ == '__main__':
    #A()
    B()


Measured memory_bytes: 3064
import java.util.*

val sc = Scanner(System.`in`)

fun main(args : Array<String>) {
    val (n, k) = listOfInt(2)
    val hh = IntArray(n){ sc.nextInt() }
    hh.sort()

    var min = Int.MAX_VALUE

    for (i in 0..n-k) {
        val diff = hh[i+k-1] - hh[i]
        if (diff < min) min = diff
    }

    println(min)
}

fun listOfInt(n: Int) = (1..n).map { sc.nextInt() }

Measured memory_bytes: 55892
from math import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(set(a))
a=list(map(lambda x: x//2, a))

def lcm(q):
  x = q[0]
  for i in range(1, len(q)):
    x = (x * q[i]) // gcd(x, q[i])
  return x

lcma=lcm(a)
for i in range(len(a)):
  if (lcma//a[i])%2==0:
    print(0)
    exit()
temp=m//lcma
print(temp//2 if temp%2==0 else temp//2+1)

Measured memory_bytes: 20372
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n = list(input())
    ans = 0
    for i in n:
        ans += int(i)
        if ans >= 9:
            ans -= 9
    if ans == 0 or ans % 9 == 0:
        print('Yes')
    else: print('No')
    
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 28636
#include <stdio.h>

int main(void)
{
    int n;
    int s[16];
    int tmp[16];
    int bucket[32];
    int cnt;
    int i;

    while (scanf("%d", &n) * n != 0){
        for (i = 0; i < n; i++){
            scanf("%d", &s[i]);
        }

        cnt = 0;
        while (1){
            for (i = 0; i < 32; i++){
                bucket[i] = 0;
            }

            for (i = 0; i < n; i++){
                bucket[s[i]]++;
            }
            for (i = 0; i < n; i++){
                tmp[i] = bucket[s[i]];
            }

            for (i = 0; i < n; i++){
                if (tmp[i] != s[i]){
                    break;
                }
            }
            if (i < n){
                for (i = 0; i < n; i++){
                    s[i] = tmp[i];
                }
                cnt++;
            }
            else {
                break;
            }
        }

        printf("%d\n", cnt);
        printf("%d", s[0]);
        for (i = 1; i < n; i++){
            printf(" %d", s[i]);
        }
        printf("\n");
    }

    return (0);
}

Measured memory_bytes: 604
//Bismillah Hir Rehmanir Rahim
//Allah knows best
using namespace std;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#define endl "\n"
#define mini -10000000000000000
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
#define vi              vector<int>
#define si              set<int>
#define pb              push_back
#define mp              make_pair
#define mod             1000000007
#define rr              return 0
#define ff              first
#define in              insert
#define ss              second
#define setbits(x)      __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)
#define deb(x)          cout << #x << " = " << x << endl
int main()
{
    //freopen("in.txt","r",stdin);
    start;
    ll i,j,k,n,m;
    string s;
    cin>>s;
    n=s.size();
    if(s[n-1]=='s') cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;
    rr;
}


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

int main() {
  int a , b ;
  cin >> a >> b;
  int c = a * b ;
  cin >> c;
  if (c % 2 == 0){
    cout << " Even " << endl;
  }
  else {
    cout << " Odd " << endl;
  }
  return 0 ;
 }


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;

void Main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if (a > m)continue;
        jobs[m - a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for (int i = m - 1; i >= 0; --i) {
        for (int b : jobs[i]) {
            q.push(b);
        }
        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5632
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
	ull M1, D1, M2, D2;
  cin >> M1 >> D1;
  cin >> M2 >> D2;
  if (M1 != M2) cout << 1 << endl;
  else cout << 0  << endl;

}


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

int main(){
    int n;cin>>n;
    int a[100000];
    for(int i=0;i<n;++i)cin>>a[i];

    sort(a,a+n);
    int ans=0;
    int rec=0;
    for(int i=0;i<n-1;++i){
        if(a[i] == a[i+1]){
            ++rec;
        }
        else{
            if(rec%2==0)++ans;
            rec = 0;
        }
    }
    if(rec%2==0)++ans;
    cout<<ans<<endl;
}

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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
vector<int>t;
int n,c,k;
bool good(int num)
{
    int cnt=1;
    int last=t[0];
    int numofPass=1;
    for(int i=1;i<n;i++)
    {
        if(numofPass==c)
        {
            last=t[i];
            cnt++;
            numofPass=1;
        }
        else if(t[i]<=last+k)
        {
            numofPass++;
        }
        else{
            cnt++;
            last=t[i];
            numofPass=1;
        }
    }
    cout<<cnt<<endl;
    return true;
}
int32_t main() {
    nitin;
    cin>>n>>c>>k;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        t.push_back(a);
    }
    sort(t.begin(),t.end());
    good(0);
    return 0;
}


Measured memory_bytes: 4256