akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
  ll n,q;
  cin>>n;
  vector<ll> a(n);
  map<ll,ll> ma;
  set<ll> s;
  ll ans =0;
  for(ll i=0; i<n; i++){
    ll tmp;
    cin>>tmp;
    s.insert(tmp);
    if(ma.count(tmp) ) ma.at(tmp)++;
    else ma[tmp] = 1;
    ans += tmp;
  }
  cin >> q;
  for(ll i=0 ; i<q; i++){
    ll b,c;
    cin>>b>>c;
    if(ma.count(b) ){
      ll am = ma.at(b);ma.erase(b);
      if(ma.count(c) ){
	ma.at(c) += am;
      }
      else{
	ma[c] = am;
      }
      ans = ans + am *(c-b);
    }
    cout<<ans<<endl;
  }
//    cout << fixed << setprecision(10);
}


Measured memory_bytes: 10896
#include<iostream>
using namespace std;
struct Node{int parent,left,right;};
struct Node T[100001];
#define NIL -1
int D[100001],n,dim,child,v,l,s;
void getDepth(int u,int p){
    D[u]=p;
    if(T[u].right!=NIL) getDepth(T[u].right,p);
    if(T[u].left!=NIL) getDepth(T[u].left,p+1);
}
void printchild(struct Node T[],int p,int d){
    if(d==0){
        if(T[p].left!=NIL){
            cout<<T[p].left;
            printchild(T,T[p].left,d+1);
        }
    }
    else if(T[p].right!=NIL){
            cout<<", "<<T[p].right;
            printchild(T,T[p].right,d);
     }
    
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++) T[i].parent=T[i].right=T[i].left=NIL;
    for(int i=0;i<n;i++){
        cin>>v>>dim;
        for(int j=0;j<dim;j++){
            cin>>child;
            if(j==0) T[v].left=child;
            else  T[l].right=child;
            l=child;
            T[child].parent=v;
        }
    }
    for(int i=0;i<n;i++){
        if(T[i].parent==NIL) s=i;
    }
    getDepth(s,0);
    for(int i=0;i<n;i++){
        cout<<"node "<<i<<": ";
        cout<<"parent = "<<T[i].parent<<", ";
        cout<<"depth = "<<D[i]<<", ";
        if(T[i].parent==NIL) cout<<"root, [";
        else if(T[i].left==NIL) cout<<"leaf, [";
        else cout<<"internal node, [";
        printchild(T,i,0);
        cout<<"]"<<endl;
    }
}


Measured memory_bytes: 7760
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q, dp[100010];
  char s[100010];
  cin >> n >> q;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    dp[i] = dp[i - 1];
    if (s[i - 1] == 'A' && s[i] == 'C') {
      dp[i] += 1;
    }
  }
  int l[100010], r[100010];
  for (int i = 0; i < q; ++i) {
    cin >> l[i] >> r[i];
  }
  for (int i = 0; i < q; ++i) {
    cout << (dp[r[i] - 1] - dp[l[i] - 1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let t_arr = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let m = Scanf.scanf "%d " (fun a -> a) in
  let px_lst = Array.to_list @@ Array.init m (fun _ -> Scanf.scanf "%d %d " (fun a b -> a-1,b)) in

  let orig_sum = Array.fold_left (+) 0 t_arr in
  let rec aux res = function
    | [] -> res
    | (p,x) :: tl -> aux ((orig_sum + x - t_arr.(p))::res) tl
  in
  let ans = List.rev @@ aux [] px_lst in
  List.iter (fun x -> Printf.printf "%d\n" x) ans



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

int N, L; string S;

struct State { vector<vector<int>>v; };

State Initialize(int H, int W) {
	State S; S.v = vector<vector<int>>(H, vector<int>(W, 0));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) S.v[i][j] = i*W + j;
	}
	return S;
}
State Add(State A, State B) {
	State S = A;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			int xx = B.v[i][j], x = xx / N, y = xx%N;
			S.v[i][j] = A.v[x][y];
		}
	}
	return S;
}
State Multiple(State A, long long x) {
	State B = A, C = Initialize(N, N);
	for (int i = 0; i < 30; i++) {
		if ((x / (1 << i)) % 2 == 1) { C = Add(C, B); }
		B = Add(B, B);
	}
	return C;
}
State parse(string S) {
	vector<string>vec; string T = ""; bool J = false; int depth = 0;
	for (int i = 0; i < S.size(); i++) {
		T += S[i];
		if (i == S.size() - 1 || (depth == 0 && S[i] >= '0' && S[i] <= '9' && (S[i + 1] == '(' || S[i + 1] == 'L' || S[i + 1] == 'R' || S[i + 1] == 'U' || S[i + 1] == 'D'))) {
			vec.push_back(T); T = "";
		}
		if (S[i] == '(' || S[i] == ')') J = true;
		if (S[i] == '(') depth++;
		if (S[i] == ')') depth--;
	}
	if (vec.size() == 1 && J == false) {
		// 1 回のケース
		char F = vec[0][0]; string Y = vec[0]; int R = stoi(Y.substr(1, Y.size() - 1));
		
		State V = Initialize(N, N);
		if (F == 'L') {
			vector<int>b(N, 0);
			for (int i = 0; i < N; i++) b[(i + N - 1) % N] = V.v[R - 1][i];
			for (int i = 0; i < N; i++) V.v[R - 1][i] = b[i];
		}
		if (F == 'R') {
			vector<int>b(N, 0);
			for (int i = 0; i < N; i++) b[(i + 1) % N] = V.v[R - 1][i];
			for (int i = 0; i < N; i++) V.v[R - 1][i] = b[i];
		}
		if (F == 'U') {
			vector<int>b(N, 0);
			for (int i = 0; i < N; i++) b[(i + N - 1) % N] = V.v[i][R - 1];
			for (int i = 0; i < N; i++) V.v[i][R - 1] = b[i];
		}
		if (F == 'D') {
			vector<int>b(N, 0);
			for (int i = 0; i < N; i++) b[(i + 1) % N] = V.v[i][R - 1];
			for (int i = 0; i < N; i++) V.v[i][R - 1] = b[i];
		}
		return V;
	}
	if (vec.size() == 1 && J == true) {
		// 繰り返し
		string U = vec[0]; int lx = 0, rx = 0, depth2 = 0;
		for (int i = 0; i < U.size(); i++) {
			if (U[i] == '(') {
				if (depth == 0) lx = i;
				depth++;
			}
			if (U[i] == ')') {
				depth--;
				if (depth == 0) rx = i;
			}
		}
		string V1 = U.substr(lx + 1, rx - lx - 1);
		string V2 = U.substr(rx + 1, U.size() - (rx + 1));
		int V3 = stoi(V2);
		State V0 = parse(V1);
		State V = Multiple(V0, V3);
		return V;
	}
	if (vec.size() != 1) {
		// 複数に分かれているやつ
		State V = Initialize(N, N);
		for (int i = 0; i < vec.size(); i++) {
			State F = parse(vec[i]);
			V = Add(V, F);
		}
		return V;
	}
}

int main() {
	cin >> N >> L >> S;
	State G = parse(S);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) { if (j)cout << " "; cout << G.v[i][j] + 1; }
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 4620
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

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

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

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

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

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
public class UnionFind {
    private int[] data;

    public UnionFind(int size) { //初期化
        data = new int[size];
        for (int i = 0; i < size; i++) data[i] = -1;
    }

    public bool Unite(int x, int y) { //xが属しているグループとyが属しているグループを統合する
        x = Root(x);
        y = Root(y);

        if (x != y) {
            if (data[y] < data[x]) {
                var tmp = y;
                y = x;
                x = tmp;
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

    public bool IsSameGroup(int x, int y) { //xとyが同じグループに属しているかどうか
        return Root(x) == Root(y);
    }

    public int Root(int x) { //ノードxの根を求める
        return data[x] < 0 ? x : data[x] = Root(data[x]);
    }

    public int GetMem(int x) => -data[Root(x)];
}

class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        int M = cin.Int();
        var A = new int[M];
        var B = new int[M];
        for (int i = 0; i < M; i++) {
            A[i] = cin.Int();
            B[i] = cin.Int();
        }

        var ans = new long[M + 10];
        var uf = new UnionFind(N + 10);
        ans[M - 1] = (long)N * (N - 1) / 2;

        for (int i = M - 1; i > 0; i--) {
            if(uf.IsSameGroup(A[i], B[i])){
                ans[i - 1] = ans[i];
            }
            else {
                long connectA = uf.GetMem(A[i]);
                long connectB = uf.GetMem(B[i]);
                ans[i - 1] = ans[i] - connectA * connectB;
                uf.Unite(A[i], B[i]);
            }
        }

        for (int i = 0; i < M; i++) {
            Console.WriteLine(ans[i]);
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 18120
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

// graph template
template<typename T>
class edge{
    public:
        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){}
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using AdjacencyList = vector<Edges<T>>;
template<typename T>
using Matrix = vector<vector<T>>;

#ifndef GCD
#define GCD
// solve ax+by=gcd(a, b)
// return gcd(a, b)
template<typename T>
T gcd(const T a, const T b, T* const px = nullptr, T* const py = nullptr){
	if(py == nullptr){
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	T d = a;
	if(b != 0){
		d = gcd(b, a % b, py, px);
		*py -= (a / b) * *px;
	}else{
		*px = 1; *py = 0;
	}
	return d;
}
#endif

#ifndef DIVISOR
#define DIVISOR
//約数の列挙, o(sqrt(n))
template<typename T>
vector<T> divisor(T n){
	vector<T> res;
	for(T i = 1; i * i <= n; i++){
		if(n % i == 0){
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}
#endif

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

    vector<int> vec;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        vec.emplace_back(x);
    }

    int num = gcd(vec[0], vec[1]);
    if(n == 3) num = gcd(num, vec[2]);

    vector<int> res = divisor(num);
    sort(res.begin(), res.end());
    for(auto x: res) cout << x << '\n';

    return 0;
}


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

struct Dice
{
    array<int, 6> roll;
    
    void toNorth()
    {
        array<int, 6> t = roll;
        roll[4] = t[0];
        roll[0] = t[1];
        roll[5] = t[4];
        roll[1] = t[5];
    }

    void toCW()
    {
        array<int, 6> t = roll;
        roll[3] = t[1];
        roll[1] = t[2];
        roll[4] = t[3];
        roll[2] = t[4];
    }

    int isSame(Dice &d2)
    {
        for (int i=0; i<4; i++) {
            for (int j=0; j<4; j++){
                for (int k=0; k<4; k++){
                    if (roll[0] == d2.roll[0] &&
                        roll[1] == d2.roll[1] &&
                        roll[2] == d2.roll[2] &&
                        roll[3] == d2.roll[3] &&
                        roll[4] == d2.roll[4] &&
                        roll[5] == d2.roll[5]){
                            return true;
                        }
                    toCW();
                }
                toNorth();
            }
            toCW();
        }
        return false;
    }
};

int main()
{
    int count;
    Dice dice1;
    for (int i=0; i<6; i++) {
        cin >> dice1.roll[i];
    }
    
    Dice dice2;
    for (int i=0; i<6; i++) {
        cin >> dice2.roll[i];
    }

    cout << (dice1.isSame(dice2) ? "Yes" : "No") << endl;
 }


Measured memory_bytes: 3108
import math


def divisors(n, sort=False):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    if sort:
        divisors.sort()
    return divisors


def main():
    N = int(input())

    def is_ok(n, d):
        while True:
            if n % d == 0:
                n = n / d
            else:
                return n % d == 1

    count = len(divisors(N - 1)) - 1

    for div in divisors(N):
        if div == 1:
            continue
        if is_ok(N, div):
            count += 1

    print(count)


if __name__ == '__main__':
    main()


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

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;



int main(void) {
    
	int ans = 0;
	string S,s;
	cin >> S;
	int siz = S.length();
	for (int i = 0; i <= siz-1; i++) {
		for (int j = 1; j <= siz-i; j++) {
			s = S.substr(i, j);
			int num = s.length();
			int jur=0;
			for (int k = 0; k < num; k++) {
				if (s[k] == 'A' || s[k] == 'C' || s[k] == 'G' || s[k] == 'T')jur++;
				if(jur==num)ans=max(ans,num);
			}
		}
	}
	cout << ans << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s;
    cin >> s;

    s.replace(0, 4, "2018");

    OP(s);
    return 0;
}

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

int main()
{
  int a,b,c;
  int count=0;
  cin>>a>>b>>c;

  for(int i = a;i<=b;i++)
    if(c%i == 0)
      {
        ++count;
      }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  1000050LL
#define tmod            998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll n,m,k,i,j,l,r,c=0,b,a,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    char c1;
    //cin >> n >>m;

    cin >> c1;
    cout << char(c1+1) << endl;



}
    return 0;
}

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

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}



Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
x = list(map(int,input().split()))
ans = 10**6 #INF
for i in range(1,101):
    ans = min(ans,sum([(k-i)**2 for k in x]))
    #print(ans,sum([(k-i)**2 for k in x]))
print(ans)

Measured memory_bytes: 39152
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int N = (int) 1e5 + 100;
int a[N];


int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i] );

	long long ans = 0;
	int mn = 1;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == mn)
		{
			mn++;
			continue;
		}
		if (mn == 1)
		{
			ans += a[i] - 1;
			mn++;
			continue;
		}
		ans += (a[i] - 1) / mn;
	}
	printf("%lld\n", ans);




	return 0;
}



Measured memory_bytes: 640
import math

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


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def is_pairwise():
    cs = [0] * 1000010
    for i in a:
        for p, _ in factorization(i):
            if p != 1 and cs[p] == 1:
                return False
            cs[p] = 1
    return True


def is_setwise():
    c = a[0]
    for i in a:
        c = math.gcd(c, i)
    return c == 1


if is_pairwise():
    print('pairwise coprime')
elif is_setwise():
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 189408
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;
typedef vector<int> Dice;

/*
Top  [0]
Front[1]
Right[2]
Left [3]
Back [4]
Bottom[5]
*/
void roll_n(Dice &dice)
{
	int a = dice[0];
	dice[0] = dice[1];
	dice[1] = dice[5];
	dice[5] = dice[4];
	dice[4] = a;
}
void roll_e(Dice &dice)
{
	int a = dice[0];
	dice[0] = dice[3];
	dice[3] = dice[5];
	dice[5] = dice[2];
	dice[2] = a;
}
void roll_w(Dice &dice)
{
	int a = dice[0];
	dice[0] = dice[2];
	dice[2] = dice[5];
	dice[5] = dice[3];
	dice[3] = a;
}
void roll_s(Dice &dice)
{
	int a = dice[0];
	dice[0] = dice[4];
	dice[4] = dice[5];
	dice[5] = dice[1];
	dice[1] = a;
}
void roll(Dice &dice, char direction)
{
	if(direction == 'N'){
		roll_n(dice);
	}
	else if(direction == 'E'){
		roll_e(dice);
	}
	else if(direction == 'W'){
		roll_w(dice);
	}
	else{
		roll_s(dice);
	}
}
int main(void)
{	
	Dice dice(6);
	
	for(int i = 0; i < dice.size(); i++){
		cin >> dice[i];
	}
	
	string directions;
	cin >> directions;
	
	for(int i = 0; i < directions.size(); i++){
		roll(dice, directions[i]);
	}
	
	cout << dice[0] << endl;

	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
 
     lint a[26];
  int main(){
    int h,w;
    cin>>h>>w;
    rep(i,h*w){
        char x;
        cin>>x;
        lint c=x-'a';
        a[c]++;
    }
    priority_queue<lint> n;
    rep(i,26){
    if(a[i]!=0) n.emplace(a[i]);
    }
    deque<P> que;
    if(h%2==0&&w%2==0)que.push_back({4,h*w/4});
    else if(h%2==1&&w%2==1){
        int f=(h-1)*(w-1)/4;
          if(f)que.push_back({4,f});
            f=h*w-f*4-1;
            f/=2;
           if(f)que.push_back({2,f});
           que.push_back({1,1});
    }else {
        if(h%2==1)swap(h,w);
        int g=h*(w-1)/4;
        if(g)que.push_back({4,g});
        g=h*w-4*g;
        g/=2;
         if(g)que.push_back({2,g});
    }
    lint count=0;
 
    while(!n.empty()||!que.empty()){
            lint x=n.top();
            n.pop();
            lint y,z;
            tie(y,z)=que.front();
            que.pop_front();
            lint b=x/y;
            if(b<z){
                que.push_front({y,z-b});
                x-=b*y;
                if(x)n.emplace(x);
            }else{
                 x-=z*y;
                 if(x)n.emplace(x);
            }

            count++;
            if(count>20000){
                cout<<"No"<<endl;
                return 0;
            }
    }
    cout<<"Yes"<<endl;

     }
  
      
      
    

  
          
  

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

int main() {
  int N, S, M, O, P;
  cin >> S; 
  M = S /3600;
  O = S %3600/60;
  P = S %3600%60%60;
  cout << M << ":" << O << ":" << P << endl; 

}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  vector<long long>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(A.begin(),A.end());
  long long ans=0;
  for(int i=0;i<N-M;i++)ans+=A[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 4820
#include <stdio.h>
#include <string.h>

void Print(unsigned long ary[][100], int row, int col)
{
	int i, j;
	for (i = 0; i < row; i++)
	{
		for (j = 0; j < col; j++)
		{
			if (j == col-1)
				printf("%lu\n", ary[i][j]);
			else
				printf("%lu ", ary[i][j]);
		}
	}
}

int main()
{
	int n,m,l;
	int num;
	
	unsigned long A[100][100] = {0};
	unsigned long B[100][100] = {0};
	unsigned long C[100][100] = {0};
	
	int i, j, k;
	
	scanf("%d %d %d", &n, &m, &l);
	
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
		{
			int x;
			scanf("%lu", &x);
			A[i][j] = x;
		}
	
	for (i = 0; i < m; i++)
		for (k = 0; k < l; k++)
		{
			int x;
			scanf("%lu", &x);
			B[i][k] = x;
		}
	
	for (i = 0; i < n; i++)
		for (j = 0; j < l; j++)
		{
			long sum = 0;
			for (k = 0; k < m; k++)
				sum += (A[i][k] * B[k][j]);
			
			C[i][j] = sum;
		}
	Print(C, n, l);
	
	return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int n, u, k, v;
int d[101], f[101];
pair<int, vector<int> > G[101];

int ti = 1;

void dfs(int id) {
	if (d[id]) return ;
	d[id] = ti ++;

	vector<int>& adj = G[id].second;
	for (int i=0; i<(int)adj.size(); ++i) {
		dfs(adj[i]);
	}
	f[id] = ti ++;
}

int main() {
	cin >> n;
	for (int i=0; i<n; ++i) {
		cin >> u >> k;
		G[u].first = u;
		while (k --) {
			cin >> v;
			G[u].second.push_back(v);
		}
	}
	for (int i=1; i<=n; ++i) {
		dfs(i);
		cout << i << " " << d[i] << " " << f[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#define H 500000

int data[H];

void maxHeapify(int,int);

int main(){
  int h,i;

  scanf("%d",&h);
  for(i = 1;i < h+1;i++){
    scanf("%d",&data[i]);
  }
  for(i = h/2;i >= 1;i--) maxHeapify(i,h);
  for(i = 1;i < h+1;i++){
    printf(" %d",data[i]);
  }
  printf("\n");
  
  return 0;
}

void maxHeapify(int i,int h){
  int largest,put;
  
  if(2*i <= h && data[2*i] > data[i]) largest = 2*i;
  else largest = i;
  if(2*i+1 <= h && data[2*i+1] > data[largest]) largest = 2*i+1;

  if(largest != i){
    put = data[i];
    data[i] = data[largest];
    data[largest] = put;
    maxHeapify(largest,h);
  }
  
}



Measured memory_bytes: 3740
<?php
// C
fscanf(STDIN, '%s', $s);
fscanf(STDIN, '%d', $k);
$n = strlen($s);
for ($i = 0; $i < $n; $i++) {
    $lmax = min($n - $i, $k);
    for ($l = 1; $l <= $lmax; $l++) {
        $a[substr($s, $i, $l)] = true;
    }
}
$a = array_keys($a);
sort($a);
echo $a[$k - 1];

Measured memory_bytes: 6648
from scipy.optimize import minimize
import numpy as np

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

xy = np.array(xy)


def r2(ab):
    xymab = xy - ab
    return np.square(xymab).sum(1).max()


x0 = np.zeros(2)
res = minimize(r2, x0, method="Nelder-Mead", tol=1e-6)

print(res.fun ** 0.5)


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

MOD = 1000000007  # type: int


def solve(N: int, K: int):
    import itertools
    import numpy as np
    candidate = 0
    ls = list(range(0, N+1))
    ls_cumsum = np.cumsum(ls)
    ls_cumsum_re = np.cumsum(ls[::-1])
    for k in range(K, N+1):
        ls_min, ls_max = ls_cumsum[k-1], ls_cumsum_re[k-1]
        candidate += ls_max - ls_min + 1
    print((candidate+1) % MOD)

# 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()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  string a[n];
  string b[m];
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  bool flag = false;
  if (n != m) {
    rep(i, n - m) {   //マスクを縦方向に動かす
      rep(j, n - m) { //マスクを横方向に動かす
        rep(k, m) {   // check
          string tmp;
          tmp = a[i + k].substr(j, m);
          if (tmp == b[k])
            flag = true;
          else {
            flag = false;
            break;
          }
        }
        if (flag) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  } else {
    rep(i, n) {
      if (a[i] == b[i])
        flag = true;
      else {
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	signed main(){
		int a, b, c,sum;
		cin >> a >> b >> c;
		for (int i = b; i >= 1; i--) {
			if (a%i == 0 && b%i == 0) {
				sum = i;
              break;
			}
		}
		if (c%sum == 0)cout << "YES" << endl;
		else cout << "NO" << endl;
		ll
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,number;cin>>n;
    char c;
    bool trump[4][13];
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++)trump[i][j]=false;
    }
    for(int i=0;i<n;i++){
        cin>>c>>number;
        if(c=='S')trump[0][number-1]=true;
        else if(c=='H')trump[1][number-1]=true;
        else if(c=='C')trump[2][number-1]=true;
        else if(c=='D')trump[3][number-1]=true;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(trump[i][j]==false){
                if(i==0)cout<<'S'<<" "<<j+1<<endl;
                else if(i==1)cout<<'H'<<" "<<j+1<<endl;
                else if(i==2)cout<<'C'<<" "<<j+1<<endl;
                else if(i==3)cout<<'D'<<" "<<j+1<<endl;
            }
        }
    }
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int>a(n);
    double sum = 0;
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        sum+=a.at(i);
    }
    double che =4.0*m;
    che = 1/che;
    che*=sum;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(che<=a.at(i))m--;
        if(m==0){cout<<"Yes"<<endl; return 0;}
    }
    cout <<"No"<<endl;
}



Measured memory_bytes: 256
from itertools import product
NS = input()
N =int(NS)

def iter_p_adic(n):
    from itertools import product
    tmp = [('3','5','7')] * n
    return product(*tmp)
ans = 0
for k in range(3,len(NS)+1):
    for i in iter_p_adic(k):
        ls = list(i)
        if ls.count('3') > 0 and ls.count('5') > 0 and ls.count('7') > 0 and int(''.join(ls)) <= N:
            ans += 1
print(ans)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define Tree int h,int l,int r,int L,int R
#define left 2*h,l,(l+r)/2,L,R
#define right 2*h+1,(l+r)/2+1,r,L,R
#define F first
#define S second
#define Pb push_back
using namespace std;
int n,t,ans=99999;
pair < int , int > p[2000];
main ()
{
	cin>>n>>t;
	
	for (int i=1; i<=n; i++)
		cin>>p[i].S>>p[i].F;
	
	sort(p+1,p+n+1);
	
	for (int i=1; i<=n; i++)
	{
		if (p[i].F>t) break;
		
		ans=min(ans,p[i].S);
	}
	
	if (ans==99999) cout<<"TLE"<<endl;
		else cout<<ans<<endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
grid = [list(input()) for _ in range(H)]
#print(grid)
MOD = 10**9+7
dp = [[0]*W for i in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if i+1 < H and grid[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= MOD
        if j+1 < W and grid[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= MOD
print(dp[H-1][W-1])

Measured memory_bytes: 89840
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

ll N;
ll a[200010];
ll b[200010];

bool check (ll p)
{
    vector < ll > amod(N);
    vector < ll > bmod(N);
    REP(i,N) {
        amod[i] = a[i] % (1LL << (p + 1));
        bmod[i] = b[i] % (1LL << (p + 1));
    }
    sort(amod.begin(), amod.end());
    sort(bmod.begin(), bmod.end());

    ll sum = 0;
    REP(i,N) {
        sum += ( lower_bound(bmod.begin(), bmod.end(), (1LL << (p + 1)) - amod[i])
               - lower_bound(bmod.begin(), bmod.end(), (1LL << (p)) - amod[i]));
        sum += ( bmod.end() - lower_bound(bmod.begin(), bmod.end(), (1LL << (p)) + (1LL << (p + 1)) - amod[i]));
    }

    if (sum % 2) return true;
    return false;
}


int main ()
{
    cin >> N;
    REP(i,N) cin >> a[i];
    REP(i,N) cin >> b[i];

    ll ans = 0;
    REP(p,30) {
        if (check(p)) {
            ans |= (1LL << p);
        }
    }

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


Measured memory_bytes: 6548
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, q = map(int, input().split())
uf = UnionFind(n)

for _ in range(q):
    t, u, v = list(map(int, input().split()))
    if t == 0:
        uf.union(u, v)
    if t == 1:
        print(1 if uf.same(u, v) else 0)


Measured memory_bytes: 11776
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import combinations_with_replacement
def main():
    n,m,q=map(int,input().split())
    lis=list(combinations_with_replacement(range(1,m+1),n))
    ans=0
    Q=[[int(_) for _ in input().split()] for i in range(q)]
    for l in lis:
        cunt=0
        for q in Q:
            if int(l[q[1]-1])-int(l[q[0]-1])==q[2]:
                cunt+=q[3]
        ans=max(ans,cunt)
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 84180
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int ans[10100];
    for(int i=1; i<=N; i++){
        ans[i]=0;
    }
        for(int x=1; x<=105; x++){
            for(int y=1; y<=105; y++){
                for(int z=1; z<=105; z++){
                    if( (x*x+y*y+z*z+x*y+y*z+z*x)<=N ){
                        ans[x*x+y*y+z*z+x*y+y*z+z*x]++;
                    }
                }
            }
        }
    for(int i=1; i<=N; i++){
        cout << ans[i] << endl;
    }

}



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

typedef long long int ll;

const ll MAX = 1e5+2;
ll dp[MAX];

int main()
{
    ll n;
    cin>>n;
    ll ht[n+1];
    ht[0]=0;
    for(int i=1;i<=n;i++)
        cin>>ht[i];
    
    dp[0]=dp[1]=0;
    dp[2]=abs(ht[2]-ht[1]);
    
    for(int i=3;i<=n;i++)
    {
        ll val1=abs(ht[i]-ht[i-1]);
        ll val2=abs(ht[i]-ht[i-2]);
        dp[i]=min(dp[i-1]+val1,dp[i-2]+val2);
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
//		solveA(args);
//		solveB(args);
		solveC(args);
//		solveD(args);
//		solveE(args);
//		solveF(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		int N= nextInt();
		for(int i=1;i<=8;i++) {
			if(2000-i*200<=N && N<=2199-i*200) {
				pw.println(i);
				break;
			}
		}

	}
	public static void solveB(String[] args) throws Exception{
		int A = nextInt();
		int B = nextInt();
		int C = nextInt();
		int K = nextInt();

		for(int i=0;i<K;i++) {
			if(C<=B) {
				C*=2;
			}else if(B<=A) {
				B*=2;
			}
			if(C>B&&B>A) {
				pw.println("Yes");
				return;
			}
		}
		pw.println("No");
	}
	public static void solveC(String[] args) throws Exception{
		int N = nextInt();
		int K = nextInt();
		int[] A = nextInts();

		for(int i=K;i<N;i++) {
			if(A[i-K]>=A[i]) {
				pw.println("No");
			}else {
				pw.println("Yes");
			}
		}


	}

	public static void solveD(String[] args) throws Exception{

	}


	public static void solveE(String[] args) throws Exception{

	}

	public static void solveF(String[] args) throws Exception{

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 56024
#create date: 2020-06-29 13:35

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    w, h, x, y = na()
    print("{:.10f} {}".format(w*h/2, 1 if w/2==x and h/2==y else 0))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e15+7;
const ll N = 100001;
ll n,a[N],k=0;
priority_queue <ll> ak,an;

int main(){
	cin>>n;
	FOR(i,0,n){
		cin>>a[i];
	}
	FOR(i,0,n){
		ak.push(a[i]);
		an.push(a[n-1-i]);
		while(ak.top()==an.top()){
			an.pop();
			ak.pop();
			if(ak.empty())break;
		}
		if(ak.empty()&&an.empty()){
			if(k==0){
				cout<<i+1;
				k++;
			}
			else cout<<" "<<i+1;
		}
	}
	cout<<endl;
	return 0;
}


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

using namespace std;

long long dp[109][100009];

const long long INF = 1e18;

int main(){
  int N, W; cin >> N >> W;
  for(int i = 0; i < N; i++){
    long long w, v; cin >> w >> v;
    dp[i][0] = 0;
    for(int j = 1; j <= 100000; j++){
      dp[i][j] = INF;
      if(i == 0){
        if(v >= j) dp[i][j] = w;
      }
      else{
        if(v > j){
          dp[i][j] = min(w, dp[i - 1][j]);
        }
        else{
          dp[i][j] = min(dp[i - 1][j], w + dp[i - 1][j - v]);
        }
      }
    }
  }
  for(int j = 100000; j >= 0; j--) if(dp[N - 1][j] != INF && dp[N - 1][j] <= W) { cout << j << endl; break; }
  return 0;
}


Measured memory_bytes: 80128
M=998244353
S=input()
N=len(S)
d=[[0]*4001 for _ in range(4001)]
d[0][0]=1
x=0
for i in range(2*N):
	if i<N:
		x+=int(S[i])
		y=2*i+2-x
	for j in range(i+1):
		for k in range(2):d[j+1-k][i-j+k]+=i-y<=j-k<x and d[j][i-j]%M
print(d[x][y]%M)

Measured memory_bytes: 169820
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    ll a, b, x; cin >> a >> b >> x;
    ll ans = b/x - (a-1)/x;
    if(x!=1 && a==0) ans++;
    
    cout << ans << endl;
    return 0;
    
}


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

int p[10], rk[10];
int g[210][210];

int main() {
    int n, m, r;
    scanf("%d%d%d", &n, &m, &r);
    for (int i = 0; i < r; i++) {
        scanf("%d", &p[i]);
        p[i]--;
    }
    memset(g, -1, sizeof(g));
    for (int i = 0; i < n; i++) {
        g[i][i] = 0;
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        a--;
        b--;
        if (g[a][b] == -1 || g[a][b] > c) {
            g[a][b] = g[b][a] = c;
        }
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (g[i][k] != -1 && g[k][j] != -1) {
                    int val = g[i][k] + g[k][j];
                    if (g[i][j] == -1 || g[i][j] > val) {
                        g[i][j] = val;
                    }
                }
            }
        }
    }
    for (int i = 0; i < r; i++) {
        rk[i] = i;
    }
    int best = -1;
    do {
        int sum = 0;
        for (int i = 1; i < r; i++) {
            sum += g[p[rk[i - 1]]][p[rk[i]]];
        }
        if (best == -1 || best > sum) {
            best = sum;
        }
    } while (next_permutation(rk, rk + r));
    printf("%d\n", best);
    return 0;
}

Measured memory_bytes: 384
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define INF_INT 2147483647

typedef std::vector<std::vector<int>> Matrix;

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}


Matrix dist;
std::vector<int> r;
int N,M,R;
int ans = INF_INT;

void warshall_floyd(int n){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for (int k = 0; k < n; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i]+dist[i][k]);
            }
        }
    }
}




int main(){
    int N; cin >> N;
    long long H,W; cin >> H >> W;
    int ans;
    for (int i = 0; i < N; i++) {
        long long a,b; cin >> a >> b;
        if(H <= a && W <= b){
            ans++;
        }
    }
    cout << ans << endl;


    return 0;

}


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

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


int main()
{
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    long long ans = 1e+18;
    // 何回魔法を唱えるかを全探索
    REP(i, N){
        long long time = x * i;
        if(i != 0){
            int tmp = a[N-1];
            for(int j = N-1; j >= 0; --j){
                a[j] = min(a[j], j == 0? tmp: a[j-1]);
            }
        }
        REP(j, N) time += a[j];
        ans = min(ans, time);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args){
		int n = sc.nextInt();
		List<Integer> d = new ArrayList<>(n);
		for(int i = 0; i < n; ++i){
			d.add(sc.nextInt());
		}
		
		System.out.println(calcSum(n, d));
	}
	
	static int calcSum(int n, List<Integer> d){
		int res = 0;
		
		for(int i = 0; i < n - 1; ++i){
			for(int j = i + 1; j < n; ++j){
				res += d.get(i) * d.get(j);
			}
		}
		
		return res;
	}
}

Measured memory_bytes: 21844
using System.Linq;
using System;
class A{
static void Main(){
double []CS=Console.ReadLine().Split().Select(double.Parse).ToArray();
 
var h = Math.Sin(CS[2] * (Math.PI / 180))*CS[0];
Console.WriteLine(h*CS[1]/(double)2);
var Acchi=CS[1]-Math.Cos(CS[2]*(Math.PI/180))*CS[0];
Console.WriteLine(Math.Sqrt(Acchi*Acchi+h*h)+CS[0]+CS[1]);
Console.WriteLine(h*CS[1]/(double)CS[0]);
 
}
 
}

Measured memory_bytes: 9620
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			long[] as = new long[M];
			for(int i = 0; i < M; i++) {
				as[i] = sc.nextLong();
			}
			
			final long sum = Arrays.stream(as).sum();
			
			System.out.println(sum <= N ? (N - sum) : -1);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 35584
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
typedef long long int ll;

ll N, K;
ll a[100001];
ll b;

int main(void){
	for(int i = 0; i <= 100000; i++){
		a[i] = 0;
	}
	cin >> N >> K;
	for(int i = 1; i <= N; i++){
		ll input;
		cin >> input >> b;
		a[input] += b;
	}

	ll cnt = 0;
	int ans;
	for(int i = 1; i <= 100000; i++){
		cnt += a[i];
		if(cnt >= K){
			ans = i;
			break;
		}
	}

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


Measured memory_bytes: 1024