akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

ll n;
ll f(ll x) {ll y=x; x*=x; x*=x; return y*x;}

int main() {
	qr(n);
	for(int i=-200;i<=200;i++)
		for(int j=-200;j<=200;j++)
			if(f(i)-f(j)==n) pr1(i),pr2(j),exit(0);
	return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const int INF=1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll a[10],n;
  std::cin >> n;
  rep(i,5) std::cin >> a[i];
  sort(a,a+5);

  std::cout << 5+(n-1)/a[0] << '\n';
  return 0;
}


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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    std::string S, T;
    cin >> S >> T;
    uint32_t count = 0;
    for(uint32_t i = 0 ; i < S.size() ; i++){
        if( S[i] != T[i]){
            count++;
        }
    }
    cout << count << endl;
}
int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 3;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


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

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

    def unite(self, u, v):
        u = self.find(u)
        v = self.find(v)

        if u == v:
            return

        if self.parents[u] > self.parents[v]:
            u, v = v, u

        self.parents[u] += self.parents[v]
        self.parents[v] = u

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

    def same(self, u, v):
        return self.find(u) == self.find(v)

N, M = map(int, input().split())
uf = UnionFind(N)
edges = []

for i in range(M):
    A, B = map(int, input().split())
    edges.append((A-1, B-1))

total = [N*(N-1)//2 for _ in range(M)]

for i in range(M-1):
    u, v = edges[-i-1]
    if uf.same(u, v):
        total[-i-2] = total[-i-1]
    else:
        total[-i-2] = total[-i-1] - uf.size(u) * uf.size(v)
        uf.unite(u, v)

for t in total:
    print(t)

Measured memory_bytes: 27280
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>

using namespace std;
#define MAX 1000000000

int main(){

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

    if (B % A == 0){
        cout << A + B << endl;
    }
    else{
        cout << B - A << endl;
    }

    return 0;

}

Measured memory_bytes: 256
H = int(input())
W = int(input())
N = int(input())

i = 0
j = 0
if H > W:
    while i < N:
        j = j + 1
        i = H + i
elif H < W:
    while i < N:
        j = j + 1
        i = W + i
else:
    while i < N:
        j = j + 1
        i = H + i
print(j)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int D = scan.nextInt();
        int G = scan.nextInt();
        Problem[] list = new Problem[D];
        for (int i = 0; i < D; i++) {
            Problem p = new Problem();
            int score = (i + 1) * 100;
            int count = scan.nextInt();
            int bonus = scan.nextInt();
            p.score = score;
            p.count = count;
            p.bonus = bonus;
            list[i] = p;
        }
        int[][] dp = new int[D+1][G+2000001];
        for (int i = 0; i <= D; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE);
        }
        dp[0][0] = 0;
        for (int i = 0; i < D; i++) {
            for (int j = 0; j <= G+2000000; j++) {
                if (dp[i][j] == Integer.MAX_VALUE) {
                    continue;
                }
                Problem p = list[i];
                for (int k = 0; k <= p.count; k++) {
                    if (k < p.count) {
                        if (G + 2000000 < j + p.score * k) {
                            continue;
                        }
                        dp[i+1][j + p.score * k] = Math.min(dp[i+1][j + p.score * k], dp[i][j] + k);
                    } else {
                        if (G + 2000000 < j + p.score * k + p.bonus) {
                            continue;
                        }
                        dp[i+1][j + p.score * k + p.bonus] = Math.min(dp[i+1][j + p.score * k + p.bonus], dp[i][j] + k);
                    }
                }
            }
        }
        int answer = Integer.MAX_VALUE;
        for (int i = G; i <= G + 2000000; i++) {
            answer = Math.min(answer, dp[D][i]);
        }
        System.out.println(answer);
    }
    class Problem {
        int score;
        int count;
        int bonus;
    }
}


Measured memory_bytes: 562516
#include<bits/stdc++.h>
using namespace std;
char a[105][105];
int c,d,b[105][105];
int main()
{
  int x,y,i,j;	
  cin>>x>>y;
  for(i=0;i<x;i++)
    cin>>a[i];
  for(i=0;i<x;i++)
    for(int j=0;j<y;j++)
      if(a[i][j]=='#')
      {
  b[i][j]++;
  b[i][j+1]++;
  b[i][j+2]++;
  b[i+1][j]++;
  b[i+1][j+1]++;
  b[i+1][j+2]++;
  b[i+2][j]++;
  b[i+2][j+1]++;
  b[i+2][j+2]++;
    }
  for(i=0;i<x;i++)
  {
    for(j=0;j<y;j++)
        if(a[i][j]=='#') 
		  cout<<'#';
      else 
	    cout<<b[i+1][j+1];
      cout<<endl;
  }
  return 0;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

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

    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    priority_queue<int,vector<int>,greater<int>> pq;
    vector<int> v;
    for(int i=0,x;i<a;i++) {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    while(pq.size()<x) {
        pq.push(v.back());
        v.pop_back();
    }
    v.clear();
    for(int i=0,x;i<b;i++) {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    while(pq.size()<x+y) {
        pq.push(v.back());
        v.pop_back();
    }
    for(int i=0,x;i<c;i++) {
        cin>>x;
        pq.push(x);
    }
    while(pq.size()>x+y) {
        pq.pop();
    }
    ll sum = 0;
    while(!pq.empty()) {
        sum += pq.top();
        pq.pop();
    }
    cout<<sum;
}


Measured memory_bytes: 2804
#include <atcoder/fenwicktree>
#include <cstdio>
using ll = int64_t;
#define rep(i, j, n) for (size_t i = 0; i < (int)n; ++i)

int main() {
  int n, q, t;
  ll u, v;
  scanf("%d%d", &n, &q);
  atcoder::fenwick_tree<ll> ft(n);
  rep(i, 0, n) {
    scanf("%lld", &u);
    ft.add(i, u);
  }

  while (q--) {
    scanf("%d%lld%lld", &t, &u, &v);
    if (t)
      printf("%lld\n", ft.sum(u, v));
    else
      ft.add(u, v);
  }
  return 0;
}

Measured memory_bytes: 8260
#include<iostream>
#define rep(i,n) for (int i=0;i<(n);i++)
	using namespace std;
int main() {
	//input
	int N, ans;
	cin >> N;
	//compute
	if (N % 2 == 0)ans = N / 2 - 1;
	else ans = N / 2 ;
	//output
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
def resolve():
    n = int(input())
    blue_cards = list()
    for i in range(n):
        card = input()
        blue_cards.append(card)
    blue_cards = sorted(blue_cards)
    m = int(input())
    red_cards = list()
    for i in range(m):
        card = input()
        red_cards.append(card)
    red_cards = sorted(red_cards)
    former = ""
    cards_points = []
    for card in blue_cards:
        point = 0
        if former == card:
            continue
        else:
            p = blue_cards.count(card)
            m = red_cards.count(card)
            point = p - m
            cards_points.append(point)
            former = card
    cards_points = sorted(cards_points)
    if cards_points[-1] < 0:
        print(0)
    else:
        print(cards_points[-1])
resolve()

Measured memory_bytes: 9164
n=int(input())
d=sorted(list(map(int,input().split())))#候補
m=int(input())
t=sorted(list(map(int,input().split())))#いるもの
j=0
for i in range(m):
  while d[j]<t[i]:
    j+=1
  if d[j]>t[i]:
    print("NO")
    break
  j+=1
else:
  print("YES")
      
  

Measured memory_bytes: 41268
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll N;
vl A;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    A = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    solve();
}

// 入力はすべて整数
// 2 <= N <= 2 × 10^5
// 1 <= A_i <= 10^9

// ll N, vl A
// N 人の心地よさの合計の最大値を出力せよ。
void solve(){
    sort(all(A));
    ll ans=0;
    rrep(i,N,N*2-1)ans+=A[i/2];
    cout<<ans<<endl;
}


Measured memory_bytes: 4648
#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int x;
    int y;
} point_t;
point_t a[300*300*2];
long b[300*300*2];

inline long dist(const point_t a, const point_t b){
    return labs(a.x-b.x)+labs(a.y-b.y);
}

int main(void){
    long h, w, d;
    scanf("%ld %ld %ld\n", &h, &w, &d);
    long t;
    for(long i=0; i<h; i++){
        for(long j=0; j<w; j++){
            scanf("%ld", &t);
            a[t].x = j;
            a[t].y = i;
        }
    }
    const long n = h*w;
    for(long i=0; i<n; i++){
        b[i+d] = b[i] + dist(a[i], a[i+d]);
    }
    long q;
    scanf("%ld", &q);
    long l, r;
    for(long i=0; i<q; i++){
        scanf("%ld %ld\n", &l, &r);
        printf("%ld\n", b[r]-b[l]);
    }
    return 0;
}


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

int main() {
  double N;
  cin >> N;
  double a;
  a = N / 2;
  int b;
  b = N / 2;
  
  if (a == b) { //Nが偶数
    cout << 0.5 <<endl;
  }
  else { //Nが奇数
    cout << (b + 1) / N <<endl;
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define scani(i) scanf("%d", &(i))
#define scanc(c) scanf("%c", &(c))
#define scand(d) scanf("%lf", &(d))

#define printi(i) printf("%d", (i))
#define printc(i) printf("%c", (i))
#define pr printf("\n")

#define NUM (100)

int main(int argc, char** argv){
    int n;
    scani(n);

    char ch;
    char b = 0;
    int sum = 0;

    scanc(ch);
    rep(i, n){
        scanc(ch);
        if(b != ch){
            sum++;
            b = ch;
        }
    }

    printi(sum);
    pr;

    return 0;
}



Measured memory_bytes: 128
# Aizu Problem 00175: Quaternary Notation
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

VALUES = {chr(65+i): 10+i for i in range(26)}
for i in range(10):
    VALUES[str(i)] = i
INV_VALUES = {value: key for key, value in VALUES.items()}

POWERS = {(base, power): base**power for base in range(1, 37) for power in range(200)}

def from_base(k, base_k):
    # convert integer k in base base_k to decimal (base 10)
    L = len(k)
    res = 0
    for i in range(L - 1, -1, -1):
        res += VALUES[k[i]] * POWERS[(base_k, L - 1 - i)]
    return res

def to_base(d, to_base):
    if d == 0:
        return 0
    # convert decimal integer (base 10) to base base_k
    res = ""
    for p in range(50, -1, -1):
        power = POWERS[(to_base, p)]
        m = d // power
        res += INV_VALUES[m]
        d = d % power
    while res[0] == '0':
        res = res[1:]
    return res


while True:
    n = int(input())
    if n == -1:
        break
    print(to_base(n, 4))

Measured memory_bytes: 9116
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const int inf=0x3fffffff;
const ll mod=1000000007;
const int maxn=1e5+100;
int a[maxn];
int  main()
{
	int n;
	scanf("%d",&n);
	ll sum=0,t=0;
	rep(i,1,n+1) scanf("%d",&a[i]),sum+=a[i],t+=i;
	if(sum%t)
	{
		puts("NO");
		return 0;
	}
	ll tmp=a[1];
	rep(i,1,n) a[i]=a[i+1]-a[i];
	a[n]=tmp-a[n];
	ll d=sum/t;
	rep(i,1,n+1)
	{
		a[i]-=d;
		if(a[i]%n||a[i]>0)
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>
#include <string>
#include <typeinfo>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int B;
  int m = N;
  for (int A = 1; A < N; A++) {
    B = N - A;
    int s = 0;
    string a, b;
    a = to_string(A);
    b = to_string(B);
    for (int i = 0; i < a.size(); i++) {
      char a_c = a[i];
      s += atoi(&a_c);
    }
    for (int i = 0; i < b.size(); i++) {
      char b_c = b[i];
      s += atoi(&b_c);
    }
    //cout << s << endl;
    if (s < m) {
      m = s;
    }
  }
  cout << m << endl;
  return 0;
}


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

vector<int> primes={2,3,5,7};
int primes_extend(int calc_from, int calc_to);
int factoring(int n, map<int,int> &factors);

int main()
{

	primes_extend(10,100);
	primes_extend(100,10000);

	int n;
	cin >> n;

	vector<int> multipatterns(n+1);
	multipatterns[1]=1;
	for (int i=2;i<=n;++i)
	{
		map<int,int>factors;
		factoring(i,factors);
		int count=1;
		for (pair<int,int> p:factors)
		{
			count*=(p.second+1);
		}
		multipatterns[i]=count;
	}

	int total=0;
	for (int i=1;i<=n-1;++i)
	{
		total+=multipatterns[i];
	}
	cout << total << endl;
}

int primes_extend(int calc_from, int calc_to)
{

	for (int i=calc_from;i<=calc_to;++i)
	{
		int j;
		int loop_max=sqrt(i);
		for (j=0;(primes[j]<=loop_max)&&(j<primes.size());++j)
		{
			if ((i%primes[j])==0)
			{
				// not prime...
				break;
			}
		}
		if ((j>=primes.size())||(primes[j]>loop_max))
		{
			primes.push_back(i);
		}
	}
	//fprintf(stderr,"count: %d\n",primes.size());
	return 0;
}

int factoring(int n, map<int,int> &factors)
{
	int maxfactor=sqrt(n);
	for (int i=0;(n>1)&&(primes[i]<=maxfactor);++i)
	{
		while ((n%primes[i])==0)
		{
			n/=primes[i];
			factors[primes[i]]++;
		}
	}
	if (n!=1)
	{
		factors[n]++;
	}

	return 0;
}





Measured memory_bytes: 7212
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] taskArr = new int[3];
		for (int i = 0; i < taskArr.length; i++) {
			taskArr[i] = sc.nextInt();
		}
		Arrays.sort(taskArr);
		int cost = 0;
		for (int i = 1; i < taskArr.length; i++) {
			cost += taskArr[i] - taskArr[i - 1];
		}
        System.out.println(cost);
	}
}

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

int main() {

	int n, r, p, c;
	int h[50];
	int change[50];

		while (1) {
			cin >> n >> r;
			if (n == 0)
				break;
			for (int i = 0; i < n; i++) {
				h[i] = n - i;
			}
			for (int i = 0; i < r; i++) {
				cin >> p >> c;
				for (int j = 0; j < p; j++) {
					change[j] = h[j];
				}
				for (int j = 0; j < c; j++) {
					h[j] = h[j + p - 1];
				}
				int k = 0;
				for (int j = c; j < c + p - 1; j++) {
					h[j] = change[k];
					k++;
				}
			}
			cout << h[0] << endl;
		}


	return 0;
}




Measured memory_bytes: 3068
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int j = 0;
            int k = 0;
            for(int i = 0; i < N; i++)
            {
                if(intArray[i] % 2 == 0)
                {
                    k++;
                    if(intArray[i] % 3 == 0 || intArray[i] % 5 == 0)
                    {
                        j++;
                    }
                }
            }
            if(k == j)
            {
                Console.WriteLine("APPROVED");
            }
            else
            {
                Console.WriteLine("DENIED");
            }
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 28252
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<cmath>
#define MAX 2000050
#define ll long long int

using namespace std;

string keys;
string out;
int main(){
  cin>>keys;
  for(int i=0;i<keys.size();i++){
    if(keys[i]=='0'){
      out+=keys[i];
    }
    if(keys[i]=='1'){
      out+=keys[i];
    }
    if(keys[i]=='B'){
      if(out.size()>0){
        out.erase(out.end()-1,out.end());
      }
    }
  }
  if(out.size()==0){
    cout<<"empty"<<endl;
  }
  else
    cout<<out<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int sum[30][100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    rep(i, N) {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        sum[c][s]++;
        sum[c][t + 1]--;
    }
    rep(j, 30) rep(i, 100000) sum[j][i + 1] += sum[j][i];
    int ans = 0;
    rep(i, 100010) {
        int tmp = 0;
        rep(j, 30) tmp += min(1, sum[j][i]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 15340
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

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

signed main()
{
   int n; cin >> n;
   V<int> a(n), b(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i] >> b[i];
   }

   int sum = 0;
   for (int i = n-1; i >= 0; i--) {
      int A = a[i] + sum;
      int d = ((-A % b[i]) + b[i]) % b[i];
      sum += d;
   }
   cout << sum << endl;

   return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}

const int MAX_N = 1e6 + 10;
int arr[MAX_N];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    ll sum = 0, cnt = 0;
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
        sum += arr[i];
    }
    for(int i = 0; i < n; i ++) {
        if(arr[i] * 4 * m >= sum) {
            cnt ++;
        }
    }
    if(cnt >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No " << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
#define X first
#define Y second
#define int long long int 
const int N = (int)1e6 + 10;
const int MOD = (int) 1e9 + 7;
 
int fastpower(int a, int b){
    int res = 1;
    a %= MOD;
    while(b){
        if(b&1) res = (res * a) % MOD;
        a *= a; a %= MOD;
        b >>= 1;
    }
    return res;
}
 
 
void solve(){
    //THink in reverse..
    // we want to find contribution of each gcd to happen
    // consider we have k places _ , _ , _ , _ , __ ,n.
    // gcd = 1 -> k^n ways;
    // gcd = 2 -> total multiples of 2 are k/2 -> (k/2)^n ways
    // so on until gcd = n;
    // but we need to take care of overcounting
    int n, k;
    cin >> n >> k;
    vector<int> dp(k + 1, 0);
    for(int gd = k; gd >= 1; --gd){
        int total_multiples = k/gd;
        int temp = fastpower(total_multiples, n);
        temp %= MOD;
        temp %= MOD;
        int extra = 0;
        for(int j = gd * 2; j <= k; j += gd){
            extra = (extra + dp[j]) % MOD;
        }
        dp[gd] = (temp - extra + MOD) % MOD;
    }
 
    int ans = 0;
    for(int i = 1; i <= k; ++i){
        int add = ( dp[i] % MOD * i % MOD ) % MOD;
        ans += add, ans %= MOD;
    }
 
    cout << ans << '\n';
   
    
}
 
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3988
# ABC084
# C. Special Trains
n = gets.chomp.to_i
c = []
s = []
f = []

(n-1).times do
  c_, s_, f_ = gets.chomp.split(" ").map(&:to_i)
  c << c_
  s << s_
  f << f_
end

n.times do |i|
  t = 0
  (i...(n-1)).each do |j|
    if t < s[j] then
      t = s[j]
    elsif t % f[j] == 0 then

    else
      t += (f[j] - t % f[j])
    end
    t += c[j]
  end
  puts t
end



Measured memory_bytes: 1788
def dfs(node_id):
    global current_time #書かないとローカル変数扱いされる
    go_time[node_id] = current_time
    current_time += 1

    for next_node in G[node_id]:

        if visited[next_node] == True:
            continue
        visited[next_node] = True
        dfs(next_node)

    back_time[node_id] = current_time
    current_time += 1


V = int(input())

G = [[] for i in range(V)]

visited = [False]*V

go_time = [0]*V
back_time = [0]*V

for loop in range(V):
    node_id,num,*tmp_adj = list(map(int,input().split()))
    node_id -= 1
    for i in range(num):
        G[node_id].append(tmp_adj[i]-1)

current_time = 1

for i in range(V):
    if visited[i] == True:
        continue
    visited[i] = True
    dfs(i)

for i in range(V):
    print("%d %d %d"%(i+1,go_time[i],back_time[i]))


Measured memory_bytes: 5636
x, n = map(int, input().split())
ps = set(map(int, input().split()))

if x not in ps:
   print(x)
   exit()

b, u = x, x
while True:
   b, u = b-1, u+1
   if b not in ps:
      print(b)
      exit()
   if u not in ps:
      print(u)
      exit()

Measured memory_bytes: 9188
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i;
      if v<10050:
      	ans[v]+=1
for i in range(n):
	print(ans[i+1])

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

vector <int> stones;
int n;

int main(){

	scanf("%d" , &n);
	for(int o = 0 ; o < n ; o++){
		int a;
		scanf("%d" , &a);
		stones.push_back(a);
	}

	vector <int> dp;
	dp.push_back(0);
	dp.push_back(abs(stones[1] - stones[0]));

	for(int i = 2 ; i < n ; i++){
		int a = dp[i - 1] + abs(stones[i] - stones[i - 1]);
		int aa = dp[i - 2] + abs(stones[i] - stones[i - 2]);
		dp.push_back(min(a, aa));
	}

	printf("%d\n" , dp[n-1]);

	return 0;

}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        CP sc = new CP();
        String S = sc.nextLine(), T = sc.nextLine();
        int max = Integer.MIN_VALUE;
        String p = "";
        for (int i = 0; i < S.length() - T.length() + 1; i++) {
            String j = S.substring(i, i + T.length());
            if (max < charMatch(T, j)) {
                max = charMatch(T, j);
                p = j;
            }
        }
        System.out.println(T.length() - charMatch(T, p));
    }

    static int charMatch(String A, String B) {
        int c = 0;
        for (int i = 0; i < A.length(); i++) {
            if (A.charAt(i) == B.charAt(i))
                c++;
        }
        return c;
    }

    /*****************************************************************************/
    static class CP {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        public CP() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        int nextInt() {
            return Integer.parseInt(NNNN());
        }

        long nextLong() {
            return Long.parseLong(NNNN());
        }

        double nextDouble() {
            return Double.parseDouble(NNNN());
        }

        String NNNN() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        String nextLine() {
            String spl = "";
            try {
                spl = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return spl;
        }
    }
    /*****************************************************************************/
}

Measured memory_bytes: 33304
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;

	int x3 = x2 - dy;
	int y3 = y2 + dx;
	int x4 = x3 - dx;
	int y4 = y3 - dy;

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> A(n);
  vector<int> one(43,0);
  rep(i,n){
    ll a;
    cin >> a;
    rep(j,43){
      if(a>>j & 1) one.at(j)++;
    }
    A.at(i) = a;
  }
  //rep(i,43) cout << one.at(i) << endl;
  vector<int> dp(43,0);
  bool flg = 0;
  for(int j=42;j>=0;j--){
    if(flg){
      if(one.at(j) > n-one.at(j)) dp.at(j) = 0;
      else dp.at(j) = 1;
    }else{
      if(k>>j & 1){
        if(one.at(j) >= n-one.at(j)){
          dp.at(j) = 0;
          flg = 1;
        }else{
          dp.at(j) = 1;
        }
      }else{
        dp.at(j) = 0;
      }
    }
  }
  //rep(i,43) cout << dp.at(i) << endl;
  ll res = 0;
  for(int i=42;i>=0;i--){
    if(dp.at(i) == 1){
      res *=2;
      res ++;
    }else{
      res *=2;
    }
  }
  ll ans = 0;
  rep(i,n)  ans += res^A.at(i);
  cout << ans << endl;
  
  return 0;
}
  

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
using namespace std;
int w, h, n;
char map[1024][1024];
// ??????????
int d[1024][1024];
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
int factory[16][2];
typedef pair<int, int> P;
 
 
 
//************************************
// Method:    bfs
// FullName:  bfs
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const int & sx ??x
// Parameter: const int & sy ??y
// Parameter: const int & gx ??x
// Parameter: const int & gy ??y
//************************************
int bfs(const int& sx, const int& sy, const int& gx, const int& gy)
{
	//memset(d, -1, sizeof(d));
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			d[j][i] = -1;
		}
	}
	queue<P> que;
	que.push(P(sx, sy));
	d[sx][sy] = 0;
	while (que.size())
	{
		const P p = que.front(); que.pop();
		// ????????
		if (p.first == gx && p.second == gy)
		{
			break;
		}
 
		// ?????
		for (int i = 0; i < 4; ++i)
		{
			int nx = p.first + direction[i][0];
			int ny = p.second + direction[i][1];
			// ??????,?????????
			if (0 <= nx && nx < w && 0 <= ny && ny < h && map[nx][ny] != 'X' && d[nx][ny] == -1)
			{
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
 
	return d[gx][gy];
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	cin >> h >> w >> n;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin >> map[j][i];
		}
	}
 
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (map[j][i] == 'S')
			{
				factory[0][0] = j;
				factory[0][1] = i;
				map[j][i] = '.';
			}
			else if (isdigit(map[j][i]))
			{
				int index = map[j][i] - '0';
				factory[index][0] = j;
				factory[index][1] = i;
			}
		}
	}
 
	int step = 0;
	for (int i = 0; i < n; ++i)
	{
		// ???????
		step += bfs(factory[i][0], factory[i][1], factory[i + 1][0], factory[i + 1][1]);
	}
	
	cout << step << endl;
 
	return 0;
}


Measured memory_bytes: 8152
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

multiset<int> mt;
vector<int> v[100005];


int main()
{
    NO_TLE
    int n,m,t;
    cin>>n>>m;
    LL ans=0;
    rep(i,n)
    {
        int a,b;
        cin>>a>>b;
        //mt.insert(t);
        v[a].push_back(b);
    }
    rep(i,100005)mt.insert(0);
    rer(i,1,m)
    {
        rep(j,v[i].size())
        {
            mt.insert(v[i][j]);
        }
        //if(!mt.empty())
        //{
            auto it=mt.end();
            --it;
            int x=*it;
            ans+=x;
            mt.erase(it);
        //}
    }
    cout<<ans<<endl;
    return 0;
}







































Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
int a[10];
int vis[10];
bool check(int x)
{
    while(x)
    {
        if(vis[x%10])return 0;
        x/=10;
    }
    return true;
}
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[i]);
        vis[a[i]]++;
    }
    //不能包含数字ai，求最小钱数
    int i;
    for(i=n;;i++)
    {
        if(check(i))break;
    }
    printf("%d\n",i);
}


Measured memory_bytes: 256
X,K,D=map(int,input().split())
step=-(-abs(X) // D)
if (abs(X)-step*D)>(abs(X)-(step-1)*D):
    step=step-1
if step>=K:
    print(abs(abs(X)-K*D))
else:
    if (K-step)%2==0:
        print(abs(abs(X)-step*D))
    else:
        print(D-abs(abs(X)-step*D))


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    string s;cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
struct UnionFind{
    vector<int> par,dep;
    UnionFind(int n){
        par.resize(n);
        dep.resize(n,0);
        for(int i=0;i<n;i++)par[i]=i;
    }
    int find(int x){
        if(x==par[x])return x;
        return par[x]=find(par[x]);
    }
    bool unite(int u,int v){
        u=find(u),v=find(v);
        if(u==v)return false;
        if(dep[u]<dep[v]){
            par[u]=v;
        }else{
            par[v]=u;
            if(dep[u]==dep[v]){
                dep[u]++;
            }
        }
        return true;
    }  
};
int main(){
    ll n,m,x;cin>>n>>m>>x;
    vector<ll> b(m+1);
    b[0]=1;
    for(int i=1;i<=m;i++){
        b[i]=b[i-1]*2LL%MOD;
    }
    vector<pair<P,P>> vs(m);
    for(int i=0;i<m;i++){
        int u,v;ll w;cin>>u>>v>>w;--u;--v;
        vs[i]=mp(P(w,i),P(u,v));
    }
    sort(all(vs));
    ll c1=0,c2=0,c3=0;
    for(int i=0;i<m;i++){
        ll s=vs[i].first.first;
        int id=vs[i].first.second,u=vs[i].second.first,v=vs[i].second.second;
        UnionFind uf(n);
        uf.unite(u,v);
        for(int j=0;j<m;j++){
            if(j==i)continue;
            if(uf.unite(vs[j].second.first,vs[j].second.second))s+=vs[j].first.first;
        }
        if(s<x){
            c1++;
        }else if(s==x){
            c2++;
        }else{
            c3++;
        }
    }
    if(c2==0){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    if(c1==0){
        ans=b[c3]*(b[c2]-2LL+MOD)%MOD;
    }else{
        ans=b[c3]*(b[c2]-1LL+MOD)%MOD*2LL%MOD;
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<int,int> P;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)


int main()
{
    ll n,c,k;cin>>n>>c>>k;
    vl t(n);
    fr(i,n)cin>>t[i];
    sort(t);
    ll ans = 1;
    ll f = t[0];
    ll now = 1;
    fr(i,n-1){
        if(t[i+1]-f <=k && now < c){
            now ++;
        }else{
            ans++;
            now = 1;
            f = t[i+1];
        }
    }
    cout << ans << endl;
}

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

#define forn(i,x,y) for(int i = int(x); i<int(y); i++)
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(V) V.begin(), V.end()
#define on(x, b) (x & (1LL << b))
#define trav(x, v) for(auto &x : v)

#define f first
#define s second

const int N = 1e5 + 10;

ll c2(ll x) {
    if(x < 2) return 0;
    return x * (x - 1) / 2;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    ll n, m; cin >> n >> m;
    cout << c2(n) + c2(m) << "\n";


    return 0;
}

/* don't forget to check:
   int overflow
   min/max cases (n = 1)
   printing index of sorted array
   limits for ans (start with inf)
   s = 'x' + s is linear! dont use it!
 */

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  unordered_map<long, long> us;
  us[0] = 0;
  long count = 0;
  for (long i = 1; i < S.size(); i++) {
    if (S[i-1] == 'A' and S[i] == 'C') {
      count++;
    }
    us[i] = count;
  }
  rep (i, Q) {
    long l, r;
    cin >> l >> r;
    l--;
    r--;
    cout << (us[r] - us[l]) << endl;
  }
  return 0;
}


Measured memory_bytes: 5028
t=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sumx=0
sum1=0
sum2=sum(b)
for i in range(t):
	sum1+=a[i]
	if(sum1+sum2>sumx):
		sumx=sum1+sum2
	sum2-=b[i]	
print(sumx)		

Measured memory_bytes: 3064
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=0
if (a==b):
    d+=1
if (b==c):
    d+=1
if (c==a):
    d+=1
if (d==1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.21 21:00:55
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    char c;cin >> c;
    if ('a' <= c && c <= 'z') {
        cout << "a" << endl;
    }
    else {
        cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

long long i,j,k,N,M,K,A[200001],B[200001],temp,ans,sum,n,m;

int main()
{
  cin>>N>>M>>K;
  for(i=0;i<N;i++)
  {
    cin>>A[i];
  }
  for(i=0;i<M;i++)
  {
    cin>>B[i];
  }
  sum=0;
  n=0;
  while(sum<=K && n<N)
  {
    sum+=A[n];
    n++;
  }
  
  if(sum>K)
  {
    n--;
    sum-=A[n];
  }
  
  
  m=0;
  while(sum<=K && m<M)
  {
    sum+=B[m];
    m++;
  }
  if(sum>K)
  {
    m--;
    sum-=B[m];
  }
  
  temp=n+m;
  
  for(i=n;i>=0;i--)
  {
    n--;
    sum-=A[n];
    while(sum<=K && m<M)
    {
      sum+=B[m];
      m++;
    }
    
    if(sum>K)
    {
      m--;
      sum-=B[m];
    }
    
    temp=max(temp,n+m);
    
  }
  
  
  cout<<temp;
  
  
}

Measured memory_bytes: 6756
n = int(input())

alphabet = 'abcdefghij'
s = [-1 for i in range(n)]
lst = [[] for i in range(n)]
lst[0].append(0)
ind = 0
while lst[ind] != [] or ind > 0:
    if ind < n-1 and lst[ind] != []:
        s[ind] = lst[ind].pop()
        for i in range(max(s)+1, -1, -1):
            lst[ind+1].append(i)
        ind += 1
    else:
        while lst[ind] != []:
            s[ind] = lst[ind].pop()
            ans = [alphabet[i] for i in s]
            print(''.join(ans))
        s[ind] = -1
        ind -= 1

Measured memory_bytes: 4420
#include "bits/stdc++.h"
using namespace std;

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

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			if (!ans.empty()) {
				ans.pop_back();
			}
		}
		else {
			ans.push_back(s[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}

int main() {

	int n, x; cin >> n >> x;

	int buf; cin >> buf;

	LL ans = abs(buf - x);



	for (int i = 1; i < n; i++) {
		int a; cin >> a;

		int diff = abs(a - x);
		
		ans = gcd(ans, diff);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256