akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>


int fac[310000];

int inv(int x){
  if(x==1) return 1;
  return (M-M/x)*inv(M%x)%M;
}


int comb(int n,int k){
  int x=(fac[k]*fac[n-k])%M;
  return (fac[n]*inv(x))%M;
}

int fac_init(int n){
  fac[0]=1;
  FOR(i,1,n+1){
    fac[i]=fac[i-1]*i;
    fac[i]%=M;
  }
}

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

  int n,m;
  cin>>n>>m;
  if(n<m) swap(n,m);

  if(n-m>1){
    cout<<0<<endl;
    return 0;
  }

  fac_init(n);

  int ans=fac[m];

  if(n-m==1){
    ans*=fac[n];
    ans%=M;
  }else{
    ans*=fac[n];
    ans%=M;
    ans*=2;
    ans%=M;
  }

  cout<<ans<<endl;



}

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

/*............................*/

#define uint uint64_t
#define mx 100001
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define mp make_pair
#define pb push_back
#define inf INT_MAX
#define pi acos(-1)
#define eps 1e-8
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define input(ara, n)          \
   for (int i = 0; i < n; i++) \
   scanf("%d", &ara[i])
#define inputl(ara, n)                   \
   for (long long int i = 0; i < n; i++) \
   scanf("%lld", &ara[i])
#define pf(a) printf("%d\n", a);
#define pfl(a) printf("%lld\n", a);
#define pfi(a) printf("%d ", a);
#define pfll(a) printf("%lld ", a);
#define sc(a) scanf("%d", &a)
#define scc(a, b) scanf("%d %d", &a, &b)
#define sccdbl(a, b) scanf("%lf %lf", &a, &b)
#define sccc(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scccdbl(a, b, c) scanf("%lf %lf %lf", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define sccl(a, b) scanf("%lld %lld", &a, &b)
#define scccl(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
using namespace std;
int main()
{
   // int t;
   // sc(t);
   // while (t--)
   // {

   // }
   int n,count=0;
   sc(n);
   string str;
   map<string,int>m;
   for(int i=0;i<n;i++){
      cin>>str;
      m[str]++;
   }
   vector<string>v;
   int a=-1;
   for(auto i:m){
      a=max(a,i.second);
   }
   for(auto i:m){
      if(i.second==a){
         v.pb(i.first);
      }
   }
   sort(v.begin(),v.end());
   for(int i=0;i<v.size();i++){
      cout<<v[i]<<'\n';
   }
   return 0;
}


Measured memory_bytes: 27352
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define debug cout << "here!"
#define pii pair<int , int>
#define pdd pair<double , double>
#define F first
#define S second
const int maxn = 1e5 * 5 + 10 , inf = 1e9 , pi = 3.14159265;
int a , b , c;
void solve(){
    
}
void in(){
    cin >> a >> b >> c;
    if (a + b + c >= 22){
        cout << "bust"; return ;
    }
    cout << "win"; return ;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    in();
    return 0;
}


Measured memory_bytes: 3620
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=sum(b)
for i in range(n-1):
    if a[i]==a[i+1]-1:
        ans+=c[a[i]-1]
print(ans)

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

int main(){
  int count=0;
  int A,B,C;
  cin>>A>>B>>C;
  if(A+B+C>=22){
    cout<<"bust";
  }
  else{
    cout<<"win";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;

const double PI = acos(-1.0);
int H,W;
int c[10][10];
int A[216][216];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin>>H>>W;
    rep(i,10)rep(j,10){
        cin>>c[i][j];
    }
    rep(i,H)rep(j,W){
        cin>>A[i][j];
    }
    rep(k,10)rep(i,10)rep(j,10){
        chmin(c[i][j], c[i][k] + c[k][j]);
    }
    ll ans = 0;
    rep(i,H)rep(j,W){
        if(A[i][j] == -1)continue;
        ans += c[A[i][j]][1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;
use std::cmp::min;

fn main(){
    let (s,t) = (read::<String>(),read::<String>());
    let mut sv : Vec<_> = s.chars().collect();
    sv.sort();
    let mut tv : Vec<_> = t.chars().collect();
    tv.sort_by(|a, b| b.cmp(a));
    let mut flag = 1;
    for i in 0..min(sv.len(),tv.len()){
        if sv[i] > tv[i]{
            flag = 0;
            break;
        }else if sv[i] < tv[i]{
            flag = 1; 
            break;
        }else{
            flag = -1;
        }
    }    
    println!("{}", if flag==1 || (flag==-1 && sv.len()<tv.len()) {"Yes"} else {"No"})
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
N, M, X, Y = map(int, input().split())
left = list(map(int, input().split()))
right = list(map(int, input().split()))

max_l = max(left)
min_r = min(right)

flag = 0

for i in range(-100, 101):
  if X < i <= Y and max_l < i <= min_r:
    print("No War")
    flag = 1
    break
    
if not flag:
  print("War")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#define int long long
using namespace std;
multiset<int>l;
multiset<int>::iterator itr;
signed main() {
	int q; cin >> q;
	int ra = 0, rb = 0;
	for (int i = 0; i < q; i++) {
		int p; cin >> p;
		if (p == 1) {
			int a, b; cin >> a >> b;
			rb += b;
			if (!i) {
				l.insert(a);
				itr = l.begin();
			}
			else {
				l.insert(a); ra += abs(a - *itr);
				if (*itr > a) { if (l.size() % 2 == 1)ra -= *itr - *(--itr); else itr--; }
				if (l.size() % 2 == 0)itr++;
			}
		}
		else {
			if (l.size() % 2 == 0)itr--;
			cout << *itr << ' ' << ra + rb << endl;
			if (l.size() % 2 == 0)itr++;
		}
	}
	cin >> q;
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct Process {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) {return a<b ? a: b;}

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);

	for (int i=1;i<=n;i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1; tail = n + 1;

	while( head != tail) {
		u = dequeue();
		c = min(q,u.t);
		u.t -= c;
		elaps += c;
		if ( u.t > 0) enqueue(u);
		else{
			printf("%s %d\n", u.name, elaps);
		}
	}
	return 0;
}



Measured memory_bytes: 11856
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>    //pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init, i, n) for (int i = init; i < (n); i++)
#define ll long long
#define rev(s) reverse(s.begin(), s.end())
#define sor(v) sort(v.begin(), v.end())
#define PI 3.14159265358979323846264338327950
//コード自動整形 Shift + Option + F @vscode
using namespace std;

/////main/////
int main()
{
    ll n, m, x;
    cin >> n >> m >> x;
    vector<ll> c(n);

    vector<vector<ll>> a(n, vector<ll>(m));
    rep(0, i, n)
    {
        cin >> c.at(i);
        rep(0, j, m)
        {
            cin >> a.at(i).at(j);
        }
    }

    ll output = 100000000;

    ll bitmax = 1 << (n);
    bitmax -= 1;
    //cout << "bitmax=" << bitmax << endl;//
    ll sum;
    ll count;

    rep(0, k, bitmax)
    {
        ll kingaku = 0;
        ll ntemp = 0;
        ll bittemp = k;
        rep(0, i, n)
        {
            bittemp = k;
            if ((bittemp >> i & (ll)1)==0)//(bittemp >> i & (ll)1)
            {
                ntemp++;
            }
        }
        //cout << "ntemp=" << ntemp << endl;//
        sum = 0;
        count = 0;
        vector<ll> rikaido(m);
        rep(0, i, n)
        {
            bittemp = k;
            if ((bittemp >> i & (ll)1)==0)
            {
                kingaku += c.at(i);
                rep(0, j, m)
                {
                    rikaido.at(j) += a.at(i).at(j);
                }
            }
        }
        rep(0, j, m)
        {
            if (rikaido.at(j) >= x)
            {
                count++;
            }
        }
        if (m == count)
        {
            output = min(output, kingaku);
        }
    }
    if (output == 100000000)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << output << endl;
    }
}
/////main/////

/////function/////

Measured memory_bytes: 3564
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

const int sz = 200009;
std::vector<ll> g[sz];
ll rnk[sz], par[sz];

ll find(ll x) {
	if (x == par[x])	return x;
	return par[x] = find(par[x]);
}

ll unite(ll x, ll y) {
	x = find(x), y = find(y);
	if (x == y)	return 0;
	if (rnk[x] < rnk[y]) {
		swap(x, y);
	}
	rnk[x] += rnk[y];
	par[y] = x;
	return 0;
}

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

	ll t, i, x, j, y, 	z = 1, k, n;
	cin >> n >> t;


	rep(i, 1, n + 1, 1) {
		rnk[i] = 1;
		par[i] = i;
	}

	while (t--) {
		cin >> x >> y;
		unite(x, y);
	}

	rep(i, 1, n + 1, 1) {
		if (par[i] == i) {
			z = max(z, rnk[i]);
		}
	}

	ce(z);
	debug(z);
}



Measured memory_bytes: 11464
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n, a, b, small_sum;
vector<P> bars;

P max_p(P a, P b){
    if(double(a.first)/a.second > double(b.first) / b.second)return a;
    else return b;
    int a_integer = a.first / a.second;
    int b_integer = b.first / b.second;
    if(a_integer > b_integer)return a;
    if(a_integer < b_integer)return b;
    a.first %= a.second;
    b.first %= b.second;
    cout << a.first << " " << a.second << " " << b.first << " " << b.second << endl;
    if(a.first * b.second > a.second * b.first)return a;
    else return b;
}

P ans = P(0, 1);

Int gcd(Int a, Int b){
    if(a == 0)return b;
    return gcd(b % a, a);
}


P prime(P x){
    a = x.first;
    b = x.second;
    Int g = gcd(a, b);
    return P(a/g,b/g);
}


void clean_up(multiset<Int> &small, multiset<Int> &big){
    if(small.empty() || big.empty())return;
    while(true){
        Int small_big = *small.rbegin();
        Int big_small = *big.begin();
        if(small_big <= big_small)break;
        small.erase(prev(small.end()));
        big.erase(big.begin());
        small.insert(big_small);
        big.insert(small_big);        
        small_sum += big_small - small_big;
    }
}

int main(){
    cin >> n;
    Int difsum = 0;
    vector<Int> as;

    for(Int i = 0;i < n;i++){
        cin >> a >> b;
        bars.push_back(P(b,a));
        difsum += max(0ll, b-a);
    }
    sort(bars.begin(), bars.end());
    Int whole = 0;
    multiset<Int> small, big;

    for(Int i = 0;i < n;i++){
        Int b = bars[i].first, a = bars[i].second;
        if(b-a < 0)difsum += b-a;
        while(true){
            if(big.empty())break;
            auto it = big.begin();
            if(difsum < *it + small_sum)break;
            whole++;
            small_sum += *it;small.insert(*it);
            big.erase(it);
        }
        Int bottom = difsum - small_sum;
        Int top = b - bottom;
     
        if(bottom >= 0 && top >= 0){
            ans = max_p(ans, P(whole*(bottom+top)+bottom,n*(bottom + top)));
//            cout << b << " " << a << " " <<  difsum << " " << small_sum << " " << whole<< endl;          
        }
        
        difsum -= b-a;
        big.insert(a);        
        clean_up(small, big);
    }
    ans = prime(ans);
    cout << ans.first << " " << ans.second << endl;
    return 0;
}

Measured memory_bytes: 7024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	a := make([]int, n)
	sum := make([]int, n+1)
	for i := range a {
		a[i] = nextInt(sc)
		sum[i+1] = sum[i] + a[i]
	}
	ans := int(1e18)
	for i := 1; i < n; i++ {
		x := sum[i] - sum[0]
		y := sum[n] - sum[i]
		ans = min(ans, abs(x-y))
	}

	wtr := bufio.NewWriter(os.Stdout)
	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 4608
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
//#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll pi = acos(-1) ;
ll z =  1000000007 ;
ll inf = 100000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll fact[100] ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
//__builtin_popcount(n) -> returns number of set bits in n
const ll N = 3600000 ;
ll test_case = 1 ;  


void solve()
{
    
    string str ;
    cin >> str ;
    fo(i , str.size())
    {
        if(str[i] == '7')
        {
            cout << "Yes" << '\n' ;
            return ;
        }
    }
    cout << "No" << '\n' ;
    return ;
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
   /* #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif*/
    fact[0] = 1 ;
    for(ll i = 1 ; i < 100 ; i++)
    {
        fact[i] = (fact[i-1] * i) ;
        fact[i] %= z ;
    }
    ll t ;
    //cin >> t ;
    t = 1 ;
    while(t--)
    {
        solve() ;
    }
    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
    return 0;
}

Measured memory_bytes: 3656
n = input()
a = 0
b = 2
if len(n) % 2 == 0:
  for x in range(len(n)//2):
    a += 9 * (10 ** (b - 2))
    b += 2
    
  print(a)

elif len(n) % 2 != 0:
  if len(n) == 1:
    print(n)
  else:
    for x in range(len(n)//2):
     a += 9 * (10 ** (b - 2))
     b += 2
    print(int(n) - 10**(len(n)-1) + a + 1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			scanner.nextInt();
			String s = scanner.next();
			int k = scanner.nextInt();

			char target = s.charAt(k - 1);
			char[] cs = s.toCharArray();
			for (char c : cs) {
				if (c == target) {
					System.out.print(c);
				} else {
					System.out.print('*');
				}
			}
			System.out.println();
		}
	}

}


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

int main() {
    int n,m; cin >> n >> m;
    if(abs(n-m) > 1){
        cout <<"0"<<endl;
        return 0;
    }
    ll ans = 1;
    for (int i = 1; i <= n; i++) ans = ans * i % MOD;
    for (int i = 1; i <= m; i++) ans = ans * i % MOD;
    cout << ans * ((n == m) + 1) % MOD << endl;
}   



Measured memory_bytes: 256
require 'pp'
#IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

# use union find

# array and variables are all 0 indexed
class UnionFind
	def initialize(n)
		@parent = Array.new(n){|i| i}
		@rank = Array.new(n){1}
	end
	def find(x)
		par = @parent[x]
		if(par == x)
			return x
		else
			return @parent[x] = find(par)
		end
	end
	def union(x,y)
		root_x = find(x)
		root_y = find(y)
		if(root_x == root_y)
			#ok
			return
		end
		if(@rank[root_x] < @rank[root_y])
			@parent[root_x] = root_y
		elsif(@rank[root_x] == @rank[root_y])
			@parent[root_y] = root_x
			@rank[root_x] += 1
		else
			@parent[root_y] = root_x
		end
	end
	def same_root?(x,y)
		return find(x)==find(y)
	end
	def count_root
		arr = []
		cnt = 0
		0.upto(@parent.size-1){|i|
			pi = find(i)
			if(!arr.include?(pi))
				arr << pi
				cnt += 1
			end
		}
		dpp arr
		cnt
	end
end

N,M=gets.chomp.split(' ').map{|n| n.to_i}
Gs=Array.new(M){UnionFind.new(N)}
0.upto(M-1){|i|
	ab = gets.chomp.split(' ').map{|n| n.to_i - 1}
	0.upto(M-1){|j|
		if(i != j)
			Gs[j].union(ab[0],ab[1])
		end
	}
}

cnt = 0
0.upto(M-1){|i|
	if(Gs[i].count_root > 1)
		cnt += 1
	end
}
puts cnt




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

A = list(map(int,input().split()))

cnt = 0
mode = 0

for i in range(len(A)):
    if i == 0:
        continue
    
    if (A[i] - A[i-1] >= 0 and mode >=0) or (A[i] - A[i-1] <= 0 and mode <= 0):
        if A[i] - A[i-1] > 0:
            mode = 1
        if A[i] - A[i-1] < 0:
            mode = -1
    else:
        mode = 0
        cnt += 1

print(cnt+1)


Measured memory_bytes: 62704
import numpy as np

def nCr(n, r):
    c = 1
    for i in range(n - r + 1, n + 1):
        c *= i
    for i in range(1, r + 1):
        c //= i
    return c

if __name__ == '__main__':
    
    N, A, B = map(int, input().split())
    v0 = list(map(int, input().split()))    
    v = np.array(v0, dtype = np.int64)
    v = np.sort(v)[::-1]
    
    ave = 0
    comb = 0
    
    if v[A - 1] == v[0]:
        ave = v[0]
        n = np.sum(v == v[0])
        for i in range(A, min(B, n) + 1):
            comb += nCr(n, i)
    else:
        n0 = np.sum(v > v[A - 1])
        n1 = np.sum(v == v[A - 1])
        comb = nCr(n1, A - n0)
        ave = np.sum(v[0: A]) / A
        
    print(ave)
    print(comb)
    
    

Measured memory_bytes: 21628
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    ld d;
    cin >> n >> d;

    ll ans = 0;
    rep(i, n){
        ld x, y;
        cin >> x >> y;
        if(sqrt(pow(x, 2) + pow(y, 2)) <= d){
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3744
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/
 
int main() {
    LL n;
    read(n);
    LL m=2*(n/11);n%=11;
    if(n) {
        if(n<=6) m+=1; else m+=2;
    }
    printf("%lld\n",m);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	sort(A, A + N);
	ll res = 0;
	ll m = A[(N - 1) / 2];
	if(N % 2 == 0) {
		res -= A[(N - 1) / 2 + 1] - m;
	}
	else {
		res -= min(abs(A[(N - 1) / 2 - 1] - m), abs(A[(N - 1) / 2 + 1] - m));
	}
	rep(i, 0, N) {
		res += 2 * abs(A[i] - m);
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1024
from collections import Counter


def main():
    # *** Sample ***
    # num: count -> 1: 1, 2: 5, 3: 3
    # base     = 1_C_2 + 5_C_2 + 3_C_2
    # remove-1 = 0_C_2 + 5_C_2 + 3_C_2 = base - 0_C_1 (0_C_1 + 0_C_2 = 1_C_2)
    # remove-2 = 1_C_2 + 4_C_2 + 3_C_2 = base - 4_C_1 (4_C_1 + 4_C_2 = 5_C_2)
    # remove-3 = 1_C_2 + 5_C_2 + 2_C_2 = base - 2_C_1 (2_C_1 + 2_C_2 = 3_C_2)
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    base_num = sum([n * (n - 1) // 2 for n in counter.values()])
    for k in range(N):
        print(base_num - (counter[A[k]] - 1))


if __name__ == '__main__':
    main()

Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int n;
  cin >> n;
  int count=1;
  for(int i=0; i<n; i++){
    int p;
    cin >>p;
    if(p==count){
      count++;
    }
  }
  if(count==1){
    cout << -1 << endl;
    return 0;
  }
  cout << n-count+1 << endl;
}



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

const int INF = 1000;

// Applies the permutation perm on the bits of x.
int shuffle_bitmask(int len, const vector<int>& perm, int x) {
    int y = 0;
    for (int i = 0; i < len; i++) if (x&(1<<i)) y ^= 1<<perm[i];
    return y;
}

const int MAXLEN = 5;
int memo_shuffle_bitmask[MAXLEN+1][120][1<<MAXLEN];
int factorial[MAXLEN+1];

// Precompute the factorials and shuffle_bitmask.
// The precomputation of shuffle_bitmask is not necessary, but it makes the code
// much faster.
void preprocessing() {
    factorial[0] = factorial[1] = 1;
    for (int n = 2; n <= MAXLEN; n++) {
        int z = 0;
        factorial[n] = n * factorial[n-1];
        vector<int> perm(n);
        for (int i = 0; i < n; i++) perm[i] = i;
        while (next_permutation(perm.begin(), perm.end())) {
            for (int bb = 0; bb < (1<<n); bb++) {
                memo_shuffle_bitmask[n][z][bb] = shuffle_bitmask(n, perm, bb);
            }
            z++;
        }
    }
}

// Returns whether conf is name-preserving.
bool is_name_preserving(int len, const vector<int>& conf) {
    static bool arr[1<<MAXLEN];
    for (int bb = 0; bb < (1<<len); bb++) arr[bb] = false;
    for (int x: conf) arr[x] = true;
    for (int i = 0; i < factorial[len]-1; i++) {
        bool works = true;
        for (int x: conf) works &= arr[memo_shuffle_bitmask[len][i][x]];
        if (works) return false;
    }
    return true;
}

// Enumerate configurations of q distinct subsets of {0, ..., len-1}; counting how many are name-preserving.
// A configuration is identified with a q-subset of {0, 1, ..., (2^len)-1}.
int count_name_preserving(int len, int q, int last, vector<int>& curr) {
    if (q == 0) return is_name_preserving(len, curr);
    int res = 0;
    for (int i = last+1; i < (1<<len) and res/factorial[len] <= INF; i++) {
        curr.push_back(i);
        res += count_name_preserving(len, q-1, i, curr);
        curr.pop_back();
    }
    return res;
}

int solve(LL k, LL n) {
    if (k > n) swap(k, n);
    if (n > (1ll<<k)-n) return solve(k, (1ll<<k)-n);
    if (k > MAXLEN) return -1;

    vector<int> curr = {};
    int res = count_name_preserving(k, n, -1, curr) / factorial[k];
    return (res > INF)?-1:res;
}

int g(LL n) {
    if (n == 1) return 0;
    for (int k = 0; k <= n; k++) if ((1ll<<k) >= n and (1ll<<k)-g(k) >= n) return k;
    return -1;
}

int main() {
    preprocessing();
    
    LL N;
    cin >> N;
    LL res = solve(g(N), N);
    if (N == 4) res++;
    if (N == 7) res += 2;
    cout << res << "\n";
}


Measured memory_bytes: 3680
import java.util.*;
import java.math.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}
class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int n = in.nextInt(), t = in.nextInt();
		String str = in.next();
		String[] s = str.split("\\+", 0);
		String ns = Integer.toString(n);
		String ts = Integer.toString(t);
		BigInteger bi = new BigInteger("0");
		for(int i = 0; i < s.length; i++){
			String tmp = s[i].substring(2);
			BigInteger b = new BigInteger(ns);
			//System.out.println(b.pow(Integer.valueOf(tmp)).toString());
			bi = bi.add(b.pow(Integer.valueOf(tmp)));
			//System.out.println(bi.toString());
		}
		bi = bi.multiply(new BigInteger(ts));
		BigInteger tle = new BigInteger("1000000000");
		if(bi.compareTo(tle) == 1){
			System.out.println("TLE");
		}
		else{
			System.out.println(bi.toString());
		}
	}


	
}

// while(in.hasNext()){
		// 	int n = in.nextInt();
		// 	if(n == 0) return;
			
		// }

Measured memory_bytes: 26420
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(true){
	    int n = kbd.nextInt();
	    if(n==0) break;
	    while(n-- > 0) solve();
	}
    }

    static void solve(){
	long[] a = new long[4];
	long[] b = new long[4];
	int i;
	for(i=0; i<4; i++){
	    a[i] = kbd.nextLong();
	}	
	for(i=0; i<4; i++){
	    b[i] = kbd.nextLong();
	}

	long[] ans = new long[4];

	ans[0] = a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3];
	ans[1] = a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2];
	ans[2] = a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1];
	ans[3] = a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0];

	System.out.println(ans[0]+" "+ans[1]+" "+ans[2]+" "+ans[3]);
    }
}

Measured memory_bytes: 23596
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli fact[N];
lli inv[N];

lli modexp(lli a, lli n) {
    lli ans = 1;
    while(n) {
        if(n & 1) {
            ans = (ans * a) % mod;
        }
        a = (a * a) % mod;
        n >>= 1;
    }
    return ans ;
}

void solve()
{
    lli n, k;
    cin>>n>>k;
//    fact[0] = fact[1] = 1;
//    inv[0] = inv[1] = modexp(1, mod - 2);
//    for(int i = 2; i < N ; i ++) {
//        fact[i] = fact[i - 1] * i;
//        inv[i] = modexp(fact[i], mod - 2);
//    }
//

    lli ans = 1;
    for(int i = k; i <= n; i ++) {
        lli t = (i * (n - i + 1)) % mod;
        ans = (ans + t + 1) % mod;
    }
    cout<<ans;
    cout<<'\n';
    return ;
}

/*
*/

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

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



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tp;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<LL, pii> plpii;
typedef pair<LD, LD> pdd;
typedef pair<LD, int> pdi;
typedef pair<LD, LL> pdl;
typedef pair<int, LD> pid;
typedef pair<LL, LD> pld;
const int mod = 1e9 + 7;
const int hf = 999983;
const int N = 1e6;

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    LD ans = 0;
    for(int i=1;i<=min(n, k-1);i++){
        int x = i;

        LD prob = 1.0/n;
        while(x < k){
            x*=2;
            prob *= 0.5;
        }
        ans += prob;
    }
    for(int i=k;i<=n;i++){
        if(i >= k) ans += 1.0/n;
    }
    printf("%.20Lf\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    char s[100];
    cin>>s;
    if(s[2]==s[3])
    {
        if(s[4]==s[5])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int[] vector = new int[2];
		vector[0] = x2 - x1;
		vector[1] = y2 - y1;

		int swap = vector[0];
		vector[0] = -1 * vector[1];
		vector[1] = swap;

		int x3 = x2 + vector[0];
		int y3 = y2 + vector[1];

		swap = vector[0];
		vector[0] = -1 * vector[1];
		vector[1] = swap;

		int x4 = x3 + vector[0];
		int y4 = y3 + vector[1];

		System.out.println(x3+" "+y3+" "+x4+" "+y4);
	}
}

Measured memory_bytes: 22612
N = int(input())
h = list(map(int,input().split()))

dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2,N):
    firstchoice = abs(h[i] - h[i-1]) + dp[i-1]
    secondchoice = abs(h[i] - h[i-2]) + dp[i-2]
    choice = min(firstchoice,secondchoice)
    dp[i] = choice
print(dp[N-1])

Measured memory_bytes: 52208
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < pair < ll, ll >, ll >&a,const pair < pair <ll, ll>, ll >&b){
    return (a.ff.ff > b.ff.ff ||(a.ff.ff == b.ff.ff && a.ss > b.ss));
}

signed main(){ 
    IOS
    //io_set();
    ll a, b, c;
    cin >> a >> b >> c;
    ll x = a-b;
    ll ans;
    if(c > x){
        ans = c-x;
    }
    else{
        ans = 0;
    }
    cout << ans << endl;
    return 0;
} 

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

using ll = long long;

int main(){
    int n;
    scanf("%d", &n);
    ll ans = 0;
    for (int i = 1; i <= n; ++ i){
        ans += 1ll * i * (n - i + 1);
    }
    for (int i = 0; i < n - 1; ++ i){
        int u, v;
        scanf("%d%d", &u, &v);
        if (u > v){
            std::swap(u, v);
        }
        ans -= 1ll * u * (n - v + 1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3820
(* Vicfred
 * https://atcoder.jp/contests/abc141/tasks/abc141_a
 * implementation
 * *)
Scanf.scanf "%s\n" (fun s ->
    if s = "Sunny" then "Cloudy"
    else if s = "Cloudy" then "Rainy"
    else "Sunny"
) |> Printf.printf "%s\n"



Measured memory_bytes: 3692
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		Set<Integer> set = new HashSet<Integer>();

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();

			if (set.contains(a)) {
				set.remove(a);
			} else {
				set.add(a);
			}
		}

		System.out.println(set.size());

		sc.close();
	}
}


Measured memory_bytes: 57788
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
#define int long long
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
typedef long long ll;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }


signed main() {
  int N,C,K;
  cin >> N >> C >> K;
  vector<int> T(N);
  ll max=-10;
  REP(i,N) {
    cin >> T[i];
  }
  sort(T.begin(),T.end());
  int cur=0;
  int ans=0;  // 時刻T[i]に到着する全員を乗せるのに必要な最小時間を計算する
  while(cur<N) {
    int nex = cur;
    // ans番目のバスが次の客を乗せられるのは以下の条件を満たすときと同値．
    while (nex<N && (nex - cur < C) && T[nex] - T[cur] <= K)
      nex++;
    ans++;
    cur=nex;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int h, w, d;
    cin >> h >> w >> d;

    vector<vector<int>> a(h, vector<int>(w));
    for(int i = 0 ; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    int qn;
    cin >> qn;
    vector<pair<int,int>> q(qn);

    for(int i = 0; i < qn; i++){
        cin >> q[i].first >> q[i].second;
    }

    unordered_map<int, pair<int,int>> mp;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            mp[a[i][j]] = make_pair(i, j);
        }
    }

    vector<int> sum(h * w + 1, 0);

    for(int i = 0; i <= d; i++){
        for(int j = i; j <= h * w; j += d){
            sum[j] = sum[j - d] + abs(mp[j].first - mp[j - d].first) + abs(mp[j].second - mp[j - d].second);
        }
    }

    for(int i = 0; i < qn; i++){
        cout << sum[q[i].second] - sum[q[i].first] << endl;
    }
}

Measured memory_bytes: 9544
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);



int main() {
    ios_base::sync_with_stdio(false); 

    string s;
    cin >> s;
    int n=s.size();
    int g=0,p=0;
    int ans=0;
    rep(i,n) {
        if (s[i]=='g') {
            if (p<g) {
                ++ans;
                ++p;
            } else ++g;
        } else {
            if (p<g) ++p;
            else {
                --ans;
                ++g; 
            }
        }
    }

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


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
#define MP(a, b) make_pair(a, b)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll h, w, N;
ll a[501][501];
bool visited[501][501];
int main() {
    vector<pair<pair<ll, ll>, pair<ll, ll>>> vp;
    cin>>h>>w;
    REP(i, 0, h){
        REP(j, 0, w){
            cin>>a[i][j];
        }
    }

    REP(i, 0, h){
        if(i%2==0){
            REP(j, 0, w-1){
                if(a[i][j]%2!=0){
                    a[i][j+1]++;
                    vp.emplace_back(MP(MP(i, j), MP(i, j+1)));
                }
            }
            if(i!=h-1 && a[i][w-1]%2!=0){
                a[i+1][w-1]++;
                vp.emplace_back(MP(MP(i, w-1), MP(i+1, w-1)));
            }
        }
        else{
            RREP(j, 1, w){
                if(a[i][j]%2!=0){
                    a[i][j-1]++;
                    vp.emplace_back(MP(MP(i, j), MP(i, j-1)));
                }
            }
            if(i!=h-1 && a[i][0]%2!=0){
                a[i+1][0]++;
                vp.emplace_back(MP(MP(i, 0), MP(i+1, 0)));
            }
        }
    }

    cout<<vp.size()<<endl;
    REP(i, 0, vp.size()){
        cout<<vp[i].first.first+1<<" "<<vp[i].first.second+1<<" "<<vp[i].second.first+1<<" "<<vp[i].second.second+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 8432
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>=13){
        printf("%d\n",b);
    }
    else if(a>5 && a<=12){
        printf("%d\n",b/2);
    }
    else if(a<=5){
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(K: int, N: int, A: "List[int]"):
    D = []
    for i in range(1,len(A)):
        D.append(abs(A[i]-A[i-1]))
    D.append(A[0]+K-A[-1])
    print(sum(D)-max(D))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(K, N, A)

if __name__ == '__main__':
    main()


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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n)
        cin >> a[i];
    
    // 逆順で探す.
    // 自分が倍数のうち一番大きいときはそのままやる
    // 約数として一番小さくないときは上の約数のみ参照する
    int ans[n]={0};
    REPD(i,n)
    {
        int sho = n/(i+1);
        if (sho == 1)
        {
            ans[i] = a[i];
        } else
        {
            ll counter = 0;
            FOR(roop,2,sho)
            {
                int tmp = (i + 1) * roop - 1;
                if (ans[tmp] == 1)
                {
                    counter++;
                }
                
            }
            if (counter%2==a[i]) 
                continue;
            else
                ans[i] = 1;
        }
    }
    ll ans_counter = 0;
    vector<ll> ansvec;
    REP(i,n)
    {
        if (ans[i])
        {
            ans_counter++;
            ansvec.PB(i+1);
        }
    }

    cout << ans_counter << endl;
    if (ans_counter != 0)
    {
        REP(i,SIZE(ansvec))
            cout << ansvec[i] << " ";
        cout << endl;
    }
    return 0;
}


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

int main(){
  int A,B,C;
  cin >>A >>B >>C;
  for (int i=1;i<B+1;i++){
    if((A*i)%B==C){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

    

Measured memory_bytes: 256