akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,a,b;
const int M=1e9+7;
ll ksm(ll x,ll y){
    ll s=1;
    while(y){
        if(y&1)s=(s*x)%M;
        x=(x*x)%M;
        y>>=1;
    }
    return s;
}
ll work(int x){
    ll s,c;
    s=c=1;
    for(int i=1;i<=x;i++)s=(s*i)%M;
    for(int i=n-x+1;i<=n;i++)c=(c*i)%M;
    return (c*ksm(s,M-2))%M;
}
int main(){
	in(n);in(a);in(b);
    cout<<(((ksm(2,n)-1)%M-work(a)%M-work(b)%M)%M+M)%M<<endl;
	return 0;
}

Measured memory_bytes: 256
m,d = map(int,input().split())
ans = 0
for month in range(1,m+1):
  for day in range(10,d+1):
    d1 = int(str(day)[0])
    d10 = int(str(day)[1])
    if month == d1 * d10 and d1 != 1 and d10 != 1:
      ans += 1
      
print(ans)
    
    




Measured memory_bytes: 2940
#include <stdio.h>

#define SIZE 2000000

int main() {
  int A[SIZE];
  int H=0;
  int i, key, l, largest, p, tmp;
  char com[20];
  do {
    scanf("%s", com);
    if (com[0] == 'i') {
      scanf("%d", &key);
      A[++H] = key;
      for (i=H; i>1 && A[i/2]<A[i];i/=2) {
        tmp = A[i/2];
        A[i/2] = A[i];
        A[i] = tmp;
      }

    } else if (com[1]=='x') { // extract
      printf("%d\n", A[1]);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i*2;
        largest = i;
        if (l < H && A[l] > A[i])        largest = l;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (com[2]!='d');
  return 0;
}


Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
const int N=2000100;
const int M=1e9+7;
int fac[N],n,ans,inv[N],f[N];
int fp(int x,int y){
	int ret=1;
	for (; y; y>>=1,x=(long long)x*x%M) if (y&1) ret=(long long)ret*x%M;
	return ret;
}
int c(int x,int y){
	if (x>y) return 0;
	return (long long)fac[y]*inv[x]%M*inv[y-x]%M;
}
int calcg(int deep,int x){
	return c(x,deep-x+1);
}
int main(){
	fac[0]=1; for (int i=1; i<=2000000; ++i) fac[i]=(long long)fac[i-1]*i%M;
	inv[2000000]=fp(fac[2000000],M-2); for (int i=1999999; i>=0; --i) inv[i]=(long long)inv[i+1]*(i+1)%M;
	scanf("%d",&n);
	if (n==2) return puts("1"),0;
	for (int i=1; i<n; ++i){
		f[i]=(long long)calcg(n-1,n-1-i)*fac[n-1-i]%M*fac[i]%M;
		// cerr<<f[i]<<endl;
		(ans+=(long long)((f[i]-f[i-1]+M)%M)*(i+1)%M)%=M;
	}
	cout<<ans;
}

Measured memory_bytes: 21632
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

int main(void) {
	int N, M, X;
	scanf("%d %d %d", &N, &M, &X);
	int C[12];
	int A[12][12];
	for (int i = 0; i < N; i++) {
		scanf("%d", &C[i]);
		for (int j = 0; j < M; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	int ans = 1<<30;
	bool ansFound = false;
	// cout << ans << "\n";
	for (int bit = 0; bit < (1 << N); bit++) {
		int sum = 0;
		int skill[12] = {0};
		for (int i = 0; i < N; i++) {
			if (bit & (1 << i)) {
				sum += C[i];
				for (int j = 0; j < M; j++) {
					skill[j] += A[i][j];
				}
			}
		}
		bool flag = true;
		for (int j = 0; j < M; j++) {
			// cout << sum << " " << skill[j] << "\n";
			if (skill[j] < X) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ans = min(ans, sum);
			ansFound = true;
		}
	}
	if (ansFound) printf("%d\n", ans);
	else printf("-1\n");
	return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
 
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
 
int main(){
  int n, m, cnt = 0;
  char in[8];
  bool f = true;
  scanf("%d", &n);
  while(n--){
    scanf("%s %d", in, &m);
    if(in[0] == '(') cnt += m;
    else cnt -= m;
    if(cnt < 0) f = false;
  }
 
  if(f && !cnt) puts("YES"); else puts("NO");
  return 0;
}


Measured memory_bytes: 3148
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string s1, s2;
    cin >> s1 >> s2;
    int n = s1.size(), m = s2.size();
    int dp[1010][1010]; //dp[i][j] s1のi文字目までとs2のj文字目までの編集距離
    rep(i, n+1){
        dp[i][0] = i;
    }
    rep(j, m+1){
        dp[0][j] = j;
    }
    REP(i, 1, n+1){
        REP(j, 1, m+1){
            dp[i][j] = min({dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + (s1[i-1] != s2[j-1])});
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}


Measured memory_bytes: 7108
# Your code here!
require 'set'

$N=gets.to_i
$ans=0

def ck(num)
    st=Set.new
    while(num>0)
        n=num%10
        st.add(n)
        num/=10
    end
    #puts st.size
    if(st.size>=3)
        return true
    else
        return false
    end
end

def calc(num,f)
    if(num>$N)
        return
    end
    if(!f&&ck(num))
        f=true
    end
    if(f==true)
        $ans=$ans+1
    end
    num*=10
    calc(num+3,f)
    calc(num+5,f)
    calc(num+7,f)
end

calc(0,false)
puts $ans

Measured memory_bytes: 2300
#include <iostream>

long gcd(long a,long b){
	if(a%b==0){
		return b;
	}else{
		return gcd(b,a%b);
	}
}
int main() {
	long n,m,i,j,k,ans,cur,res;
	std::cin >> n;
	ans=0;
	for(i=1; i<=n; i++){
		for(j=1; j<=n; j++){
			for(k=1; k<=n; k++){
				ans+=gcd(gcd(i,j),k);
			}
		}
	}
	std::cout << ans;
	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

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

using namespace std;

//===================================== template =========================================================

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int vx = x2 - x1, vy = y2 - y1;
    int v2x = -vy, v2y = vx;
    cout << x2 + v2x << " " << y2 + v2y << " " << x1 + v2x << " " << y1 + v2y << endl;
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
ab = [[] for i in range(N)]
for _ in range(M) :
  a, b = map(int, input().split())
  ab[a-1].append(b-1)
  ab[b-1].append(a-1)
Q = int(input())
vdc = [[int(i) for i in input().split()] for _ in range(Q)]

C = [0] * N
D = [-1] * N
for v, d, c in vdc[::-1] :
  q = deque([(v - 1, d, c)])
  while q :
    cv, cd, cc = q.popleft()
    if D[cv] >= cd :
      continue
    D[cv] = cd
    if C[cv] == 0 :
      C[cv] = cc
    for nv in ab[cv] :
      q.append((nv, cd - 1, cc))

for i in range(N) :
  print(C[i])

Measured memory_bytes: 131360
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

N = getInputInt()
A = getInputListInt()

s_sum = sum(A)

ans = [None] * N

ans[0] = s_sum
for i in range(1, N, 2):
    ans[0] -= 2 * A[i]

for i in range(N - 1):
    ans[i + 1] = 2 * A[i] - ans[i]

print(*ans)

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

int main(){
  int n;
  cin >> n;
  int a[3*n];
  rep(i,3*n)cin >> a[i];
  priority_queue<int, vector<int>, greater<int> > q1;
  priority_queue<int>q2;
  ll sum1=0;
  ll sum2=0;
  rep(i,n){
    q1.push(a[i]);
    sum1 += a[i];
  }
  rep(i,n){
    q2.push(a[2*n+i]);
    sum2 += a[2*n+i];
  }
  ll former[n+1];
  ll latter[n+1];
  rep(i,n+1){
    former[i]=sum1;
    q1.push(a[n+i]);
    sum1-=q1.top();
    q1.pop();
    sum1+=a[n+i];
  }
  rep(i,n+1){
    latter[i]=sum2;
    q2.push(a[2*n-i-1]);
    sum2-=q2.top();
    q2.pop();
    sum2+=a[2*n-i-1];
  }
  ll ans= -1e16;
  rep(i,n+1)ans = max(ans,former[i]-latter[n-i]);
  cout << ans << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

/*
 * 繰り返し自乗法
 */
//typedef long long LL;
LL power( LL x, LL n ) {
    LL res = 1;
    if( n > 0 ) {
        res = power( x, n / 2 ) % MOD;
        if( n % 2 == 0 ) res = ( res * res ) % MOD;
        else res = ( ( ( res * res ) % MOD ) * x ) % MOD;

    }
    return res % MOD;

}

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

    LL n, k;
    cin >> n >> k;
    LL res = 0;

    LL ans[SIZE];
    for(LL i = k; i >= 1; --i) {
        LL t = k / i;
        LL tmp = power(t, n) % MOD;
        res += tmp * i % MOD;
        res %= MOD;
        for(int j = i * 2; j <= k; j += i) {
            tmp -= ans[j];
            res -= ans[j] * i % MOD;
            res = (res + MOD) % MOD;

        }
        ans[i] = tmp;
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x==y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    UnionFind u(n);
    vector<ll> ans(m);
    ans[m-1] = n*(n-1)/2;

    for (ll i=m-1; i>=0; i--) {
        if (i==0) continue;
        if (u.same(a[i], b[i])) {
            ans[i-1] = ans[i];
            continue;
        }
        ll res = (ll)u.size(a[i])*u.size(b[i]);
        u.unite(a[i], b[i]); 
        ans[i-1] = ans[i] - res;
    }

    rep(i, m) {
        cout << ans[i] << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main {

	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
		        
		        int n = sc.nextInt();
		        int temp = n / 1000 * 1000;
		        int result = temp == n ? 0 : temp + 1000 - n;
		        System.out.println(result);

	}

}


Measured memory_bytes: 35700
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<math.h>

using namespace std;

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

	int a,b;
	cin >> a >> b;

	int tmp = b-a;

	int h=0;
	for(int i=1;i<tmp;i++){
		h += i;
	}
	cout << h-a << "\n"; 
				
	
	return 0;
}

Measured memory_bytes: 256
a,b,c,d=gets.chomp.split.map(&:to_i)
 
class Monster
    attr_accessor :name, :hitpoint, :attackpoint, :status
    def initialize(name, hitpoint, attackpoint, status)
        @name=name
        @hitpoint=hitpoint
        @attackpoint=attackpoint
        @status=status
    end
    
    def attackEnemy(target)
        target.receiveDamage(@attackpoint)
    end
    
    def receiveDamage(damage)
        @hitpoint-=damage
    end
    
    def isAlive
        if @hitpoint<=0
            @status="dead"
        else
            @status="alive"
        end
    end
end
 
player1=Monster.new("takahashi",a,b,"alive")
player2=Monster.new("aoki",c,d,"alive")
 
inBattle=true
attacker=player1
receiver=player2
 
while inBattle==true do
    attacker.attackEnemy(receiver)
    receiver.isAlive
    
    if receiver.status=="dead"
        inBattle=false
    else
        attacker,receiver=receiver,attacker
    end
end
 
if attacker.name=="takahashi"
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 14364
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int X, Y;

int main() {
	cin >> X >> Y;
	for (int i = 0; i <= X; i++) {
		if (2 * i + 4 * (X - i) == Y) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
	return 0;
}

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

vector<ll> h(100000 + 100,-1);
vector<ll> dp(100000 + 100,-1);

ll calc(ll i){
    if(i == 1) return 0;
    if(i == 2) return abs(h[1] - h[2]);
    if(dp[i] != -1) return dp[i];
    dp[i] = min(calc(i - 1) + abs(h[i] - h[i - 1]), 
               calc(i - 2) + abs(h[i] - h[i - 2]));
    return dp[i];
}

int main(){
    ll n;
    cin >> n;
    for(ll i = 1; i <= n; ++i){
        cin >> h[i];
    }
    cout << calc(n) << endl;
    return 0;
}


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

void solve(long long N, long long M, std::vector<long long> p, std::vector<std::string> S){
    set<int> all;
    for(int i=0;i<M;i++){
        if(S[i] =="AC"){
            all.insert(p[i]);
        }
    }
    set<int> s;
    int wa =0;
    for(int i=0;i<M;i++){
        if(S[i] =="AC"){
            s.insert(p[i]);
        }else{
            if(s.find(p[i]) == s.end() && all.find(p[i]) != all.end()){
                wa++;
            }
        }
    }
    cout << s.size() <<" "<< wa << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> p(M);
    std::vector<std::string> S(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&p[i]);
        std::cin >> S[i];
    }
    solve(N, M, std::move(p), std::move(S));
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,temp1=0,temp2=0;
  cin>>a>>b>>c;
  temp1=b;
  temp2=a;
  a=temp1;
  b=temp2;
  temp1=a;
  temp2=c;
  c=temp1;
  a=temp2;
  cout<<a<<" "<<b<<" "<<c<<'\n';
  return 0;
 
  
}

Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

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

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >>A >> B >> C;
  if (A-B>=C) cout << 0 << endl;
  else cout << C-(A-B) << endl;
 
}


Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
plist = list(map(int, input().split()))
kitaiti = np.array([(0.5*(p+1)) for p in plist])
ans = 0
val = sum(kitaiti[:K])
ans = max(ans, val)
for i in range(1, N-K+1):
    # print(i-1, i+K)
    val -= kitaiti[i-1]
    val += kitaiti[i+K-1]
    ans = max(ans, val)
print(ans)

Measured memory_bytes: 33780
def main():
    N, M, K = map(int, input().split())

    for i in range(N + 1):
        for j in range(M + 1):
            black = i * M - j * i + j * (N - i)
            if K == black:
                print('Yes')
                return
    else:
        print('No')

main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,c=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      c+=a[i]*a[j];
    }
  }
  cout<<c;
}

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

using namespace std;

#define hash sodnf9843bsd
#define ll long long
#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359
#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define YESNO(ans) cout << (ans?"YES":"NO") << endl
#define prec(x) cout << fixed << setprecision(x)
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int n, k;cin>>n>>k;
    vector<int>h(n);
    _fi(n) cin>>h[i];

    ll dp[100005] = {};
    for(int i = 0;i < n;i++) dp[i] = LINF;

    dp[0] = 0;
    for(int i = 1;i < n;i++){
        for(int j = 1;j <= k;j++){
            if (i-j < 0) break;
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
 
public class Main{
	static int ans=0;

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] route = new int[2*m][2];
		boolean[] used = new boolean[n];
		used[0] = true;
		for(int i=1; i<n; i++ ){
			used[i] = false;
		}

		for(int i=0; i<m; i++){
			route[2*i][0] = sc.nextInt();
			route[2*i][1] = sc.nextInt();
			route[2*i+1][0] = route[2*i][1];
			route[2*i+1][1] = route[2*i][0];
		}

		dfs( route, 1, used );
		System.out.println(ans);
		return;
	}

	public static void dfs( int[][] route, int start, boolean[] used ){
		boolean check = true;
		boolean[] copy = new boolean[ used.length ];

		for(int i=0; i<used.length; i++){
			if( i== start-1){
				copy[i] = true;
			}else{
				copy[i] = used[i];
			}
			check = check & copy[i];
		}

		if(check){
			ans++;
		}else{
			for(int i=0; i<route.length; i++){
				if(route[i][0] == start && !used[ route[i][1] -1 ]){
					dfs( route, route[i][1], copy );
				}
			}
		}
		return;
	}
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()

ans = list2d(M, 2, 0)
cnt = 1
for i in range(M//2):
    ans[i][0] = cnt
    cnt += 1
cnt += 1
for i in range(M//2-1, -1, -1):
    ans[i][1] = cnt
    cnt += 1
for i in range(M//2, M):
    ans[i][0] = cnt
    cnt += 1
for i in range(M-1, M//2-1, -1):
    ans[i][1] = cnt
    cnt += 1

for a, b in ans:
    print(a, b)


Measured memory_bytes: 22640
#include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int v[n],c[n];
  int max=0;
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  for(int i=0;i<n;i++){
    if(v[i]>c[i]){
      max += v[i]-c[i];
    }

  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
int R, C;
const int MAX_R = 12;
const int MAX_C = 10020;
bool omote[MAX_R][MAX_C];
int avai[MAX_C];
int avai_ori[MAX_C];  //変化させない
int main(int argc, const char * argv[])
{
    while (true) {
        scanf("%d %d", &R, &C);
        if (R == 0 && C == 0) break;
        int ret = 0;
        memset(avai_ori, 0, sizeof(avai_ori));
        memset(avai, 0, sizeof(avai));
        for (int i = 0; i < R; i++) {
            for (int j = 0; j < C; j++) {
                int n;
                scanf("%d", &n);  //表なら1,裏なら0
                omote[i][j] = n;
                if (n == 0) {//裏の場合
                    avai[j]++;
                    avai_ori[j]++;
                }
            }
        }
        
        for (int i = 0; i < (1 << R); i++) {
            for (int j = 0; j < C; j++) avai[j] = avai_ori[j];
            for (int j = 0; j < R; j++) {
                if ((i >> j)&1) {  //j行目を裏返す場合
                    for (int k = 0; k < C; k++) {
                        if (omote[j][k]) avai[k]++;
                        else avai[k]--;
                    }
                }
            }
            int sum = 0;
            for (int j = 0; j < C; j++) {
                sum += max(avai[j], R-avai[j]);
            }
            ret = max(ret, sum);
        }
        printf("%d\n", ret);
    }
    
    return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mii map<ll,ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define endl "\n"
#define deb(x) cout << #x << "=" << x << endl
const ll mod = 1e9+7;

ll msum(ll a,ll b,ll m) { return (a%m+b%m)%m; }
ll msub(ll a,ll b,ll m) { return (a%m-b%m)%m; }
ll mpro(ll a,ll b,ll m) { return ((a%m)*(b%m))%m; }
ll m_m(ll a,ll b,ll m);
ll fxp(ll a,ll b,ll m);
void swap(ll &a,ll &b){ ll t=a; a=b; b=t;}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,i;
        cin>>n;
        vi v;
        fo(i,n)
        {
            ll x;
            cin>>x;
            v.pb(x);
        }  
        ll dp[n]={0};
        dp[1]=abs(v[1]-v[0]);
        for(i=2;i<n;i++)
        {
            dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
        }
        cout<<dp[n-1]<<endl;
    }
 return 0;
}
ll fxp(ll a,ll b,ll m) {
    if(b==0)
        return 1;
    if(b%2==0)
        return fxp(m_m(a,a,m),b/2,m);
    return m_m(fxp(a,b-1,m),a,m);
}
ll m_m(ll a,ll b,ll m) 
{
    ll res=0;
    a=a%m;
    while(b)
    {
        if(b&1)
        {
            res+=a; 
            res=res%m;
        }
        a=(a*2)%m;
        b=b/2;
    }
    return res;
}

Measured memory_bytes: 4812
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	int a[100000];
	int i,j,n = 0, t = 0,c = 0,d = 0;
	cin >> s;
	if (s.length() == 1)cout << "0" << "\n";
	else {
		for (i = 0; i < s.length(); ++i) {
			if (s.substr(i, 1) == s.substr(i + 1, 1)) {
				a[n++] = i + 1;
				s.erase(0, i + 1);
				i = -1;
				continue;
			}
			if (s.length() < 1)break;
		}
		if (s.length() > 0)a[n++] = s.length();
		for (i = 0; i < n; ++i) {
			if (i % 2 == 0)c += a[i];
			else d += a[i];
		}
		if (c > d)t = d;
		else t = c;

		cout << t << "\n";
	}
	return 0;
}

Measured memory_bytes: 896
#abc 147 c bit全探索の問題 binはstr型を返す
#bin()をつかわなくてもそのままbit演算すればよし i>>k k桁右シフト
def ninzu(x):
    bit=bin(x)
    return bit.count("1")

n=int(input())
xy=[]
an=[]
ans=0
for i in range(n):
    z=[]
    a=int(input())
    an.append(a)
    for j in range(a):
        x,y=map(int,input().split())
        z.append([x,y])
    xy.append(z)
for i in range(2**n):
    flag=True
    for j in range(n):
        if (i>>j)&1:
            for x1,y1 in xy[j]:
                if y1==1:
                    if ((i>>x1-1)&1)!=1:
                        flag=False
                else:
                    if ((i>>x1-1)&1)!=0:
                        flag=False
            if flag==False:
                break
        if flag==False:
            break
    if flag:
        ans=max(ans,ninzu(i))
print(ans)

Measured memory_bytes: 3064
#C_Make_A_Rectangle

def MakeRectangle(N, A):
    A = sorted(A, reverse=True)
    length_list = list()
    length_buff = 0
    for length in A:
        if len(length_list) == 2:
            break
        if length_buff == length and length != 0:
            length_list.append(length)
            length_buff = 0
        else:
            length_buff = length
    if len(length_list) < 2:
        return 0
    else:
        return length_list[0] * length_list[1]


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    S = MakeRectangle(N, A)
    print(S)

Measured memory_bytes: 14244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
//const ll mod=1e9+7;
const ll mod=998244353;
const ll inf=5e15;

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-max
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// max-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=max(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return -inf; // max
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return max(lv,rv); // max
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmax(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};

int main() {
  ll n;
  cin >> n;
  vector<pll> a(n);
  vector<pll> b(n);
  for(ll i=0;i<n;i++) {
    ll x,d;
    cin >> x >> d;
    a[i]={x,d};
    b[i]={x,x+d};
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  segtree d(n+10);
  d.Set(0,n+1,-inf);
  vec dp(n+1);
  dp[0]=1;
  for(ll i=0;i<n;i++) {
    ll x=b[n-i-1].second;
    ll it=upper_bound(a.begin(),a.end(),pll(x,0))-a.begin();
    d.Set(n-i-1,n-i,it);
    d.Set(n-i-1,n-i,d.Getmax(n-i-1,it));
    ll id=n-d.Getmax(n-i-1,n-i);
    (dp[i+1]=dp[i]+dp[id])%=mod;
  }
  cout << dp[n] << endl;
}

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

using namespace std;

const int Maxn = 1e5+7;

int n, k, ans;
int h[Maxn];

int main()
{
    cin >> n >> k;
    for(int i = 1; i <= n; ++i)
        cin >> h[i];
    sort(h+1, h+n+1);
    ans = h[k]-h[1];
    for(int i = 2; i+k-1 <= n; ++i)
        ans = min(ans, h[i+k-1]-h[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
r, g, b, n = map(int, input().split())
s_rgb = sorted([r, g, b], reverse=True)
count = 0
for i in range(int(n / s_rgb[0]) + 1)[::-1]:
    for j in range(int((n - s_rgb[0] * i) / s_rgb[1]) + 1)[::-1]:
        tmp = n - s_rgb[0] * i - s_rgb[1] * j
        if (tmp >= 0 and tmp % s_rgb[2] == 0):
            count += 1
print(count)


Measured memory_bytes: 3060
#include <stdio.h>

int count = 0;

void dfs(int ver, int v[][10], int seen[], int n, int m){
	int end = 1;
	for(int i=0; i < n; i++) {
		if(!seen[i] && i != ver)
			end = 0;
	}
	if(end) {
		count++;
		return;
	}

	seen[ver] = 1;
	for(int i=0; v[ver][i]; i++) {
		if(seen[v[ver][i]-1])
			continue;
		dfs(v[ver][i]-1, v, seen, n, m);
	}
	seen[ver] = 0;
}

int main(void){
	int n, m, a, b, idx[10] = {0};
	int v[10][10] = {{0}};
	int seen[10] = {0};

	scanf("%d%d", &n, &m);
	for(int i=0; i < m; i++) {
		scanf("%d%d", &a, &b);
		a--; b--;
		v[a][idx[a]++] = b+1;
		v[b][idx[b]++] = a+1;
	}

	dfs(0, v, seen, n, m);
	printf("%d", count);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<LL, LL>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 5e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string s;
int n, ans[30], tree[26][4 * N];

void merge(int p, int L, int R) {
    for (int i = 0; i < 26; i++) {
        tree[i][p] = tree[i][L] + tree[i][R];
    }
}

void build(int p, int b, int e) {
    if (b == e) {
        tree[s[b] - 'a'][p]++;
        return;
    }
    int m = b + e >> 1;
    build(p * 2, b, m);
    build(p * 2 + 1, m + 1, e);
    merge(p, p * 2, p * 2 + 1);
}

void query(int p, int b, int e, int l, int r) {
    if (b > r || e < l) return;
    if (b >= l && e <= r) {
        for (int i = 0; i < 26; i++) {
            ans[i] += tree[i][p];
        }
        return;
    }
    int m = b + e >> 1;
    query(p * 2, b, m, l, r);
    query(p * 2 + 1, m + 1, e, l, r);
}

void update(int p, int b, int e, int l, int r, char v) {
    if (b > r || e < l) return;
    if (b >= l && e <= r) {
        tree[s[b] - 'a'][p]--;
        tree[v - 'a'][p]++;
        s[b] = v;
        return;
    }
    int m = b + e >> 1;
    update(p * 2, b, m, l, r, v);
    update(p * 2 + 1, m + 1, e, l, r, v);
    merge(p, p * 2, p * 2 + 1);
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cin >> n >> s;
    s = "+" + s;
    build(1, 1, n);
    int q;
    scanf("%d", &q);
    while (q--) {
        int k;
        cin >> k;
        if (k == 1) {
            int id; char c;
            cin >> id >> c;
            update(1, 1, n, id, id, c);
        } else {
            int L, R, yo = 0;
            cin >> L >> R;
            memset(ans, 0, sizeof ans);
            query(1, 1, n, L, R);
            for (int i = 0; i < 26; i++) {
                if (ans[i]) yo++;
            }
            printf("%d\n", yo);
        }
    }
    return 0;
}


Measured memory_bytes: 160664
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,a[3],b,c,ans=0,cnt=0,tmp;
string s,t;
int main(){
	cin >> s >> t;
	string ss=s;
	ss+=s;
	for(int i=0;i<s.size();i++){
		cnt=0;
		for(int j=i;j<s.size()+i;j++){
			if(ss[j]==t[j-i]){
				cnt++;
			}
		}
		if(cnt==s.size()){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	string s;
	cin >> s;
	int n;
	n = s.size();
	VC c = { 'A','T','G','C' };

	int ans = 0, cnt = 0;
	bool flag = false, flag1 = false;


	rep(i, n) {
		flag1 = false;
		rep(j, 4) {
			if (c[j] == s[i]) flag1 = true;
		}

		if (flag1) {
			cnt++;
			flag = true;
		} else {
			if (ans < cnt ) {
				ans = cnt;
				cnt = 0;
				flag = false;
			} else {
				cnt = 0;
				flag = false;
			}
		}
		//cout << cnt << endl;
	}
	if (ans < cnt) ans = cnt;
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
 
using namespace std;
 
int n,k;
const int N=1e5+5;
const int INF=2e9;
int mem[N];
int h[N];
 
int frog(int i)
{
    if (i==n-1)
        return 0;
    if (mem[i]!= -1)
        return mem[i];
 
    int ans=INF;
 
    for (int j=1;j<=k;j++){
        if (i+j <n)
            ans=min(ans,abs(h[i]-h[i+j]) + frog (i+j));
    }
    mem[i]= ans;
    return mem[i];
}
 
int main()
{
    scanf("%d %d",&n,&k);
    memset(mem,-1,sizeof mem);
    for (int i=0;i<n;i++)
        scanf("%d",&h[i]);
    printf("%d\n",frog(0));
    return EXIT_SUCCESS;
}

Measured memory_bytes: 5760
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input!{
        a: i64,
        b: i64,
        x: i64,
    }

    let min;
    let max;

    min = a / x;
    max = b / x;
    if a % x == 0 {
        println!("{}", max - min + 1);
    } else {
        println!("{}", max - min);
    }
}


Measured memory_bytes: 4352
// 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> D(N, vector<int>(2));
    REP(i, N)
    {
        cin >> D[i][0] >> D[i][1];
    }
    int ans = 0;
    int cnt = 0;
    REP(i, N)
    {
        if (D[i][0] == D[i][1])
        {
            ++cnt;
            if (cnt >= 3) ++ans;
        }
        else
        {
            cnt = 0;
        }
        
    }
    if (ans > 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    
    return 0;
}


Measured memory_bytes: 3600
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

int N;
int A[100000];

int XCOUNT[100000] = {};

void solve()
{
    REP(i, N) {
        int a = A[i];
        if(a > 0) {
            ++XCOUNT[a-1];
        }
        ++XCOUNT[a];
        if(a < 100000-1) {
            ++XCOUNT[a+1];
        }
    }

    int xcmax = *max_element(begin(XCOUNT), end(XCOUNT));
    cout << xcmax << "\n";
}

int main()
{
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if(a > b) swap(a, b);
	if(a > c) swap(a, c);
	if(b > c) swap(c, b);
	cout << ((c&1)?a*b:0) << endl;
	return 0;
}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n=I()
N=10**5+1
dp=[inf]*(N)
dp[0]=0
six=[6**i for i in range(1,7)]
nine=[9**i for i in range(6)]
a=six+nine
for i in range(n):
    for j in a:
        if i+j<N:
            dp[i+j]=min(dp[i+j],dp[i]+1)

print(dp[n])


Measured memory_bytes: 46536
N,M = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(M)]

se1 = set()
se2 = set()

for a,b in AB:
  if a>b:
    a,b = b,a
  if a == 1:
    se1.add(b)
  if b == N:
    se2.add(a)
    
se = se1 & se2
#print(se1)
#print(se2)
answer = 'POSSIBLE' if se else 'IMPOSSIBLE'
print(answer)

Measured memory_bytes: 46480
#include <iostream>


using namespace std;


int main(){
	int rooms[4][3][10] = { 0 };

	int n;

	cin >> n;

	int b, f, r, v;

	for (int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		rooms[b-1][f-1][r-1] = rooms[b-1][f-1][r-1]+v;
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			cout << " ";
			for (int k = 0; k < 10; k++){
				cout << rooms[i][j][k];
				if (k != 9) cout << " ";
			}
			cout << endl;
		}
		if (i != 3) cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
typedef pair<int,int>P;
int main(void)
{
	P box[100001];
	int n,a[100001],MAX,i,sima,flg,i1,cnt,i2;
	scanf("%d",&n);
	a[0]=-1;
	a[n+1]=-1;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	cnt=0;
	for(i=1;i<=n;i++){
		if(i>i2){
		i1=i+1;
		i2=i;
		 while(a[i]==a[i1]){
			 i1++;
			 i2++;
		   }
		box[cnt].first=a[i];
		flg=0;
		if(a[i]>a[i-1]&&a[i]>a[i1]){
			box[cnt].second=-1;
			flg=1;
		}
		if(a[i]<a[i-1]&&a[i]<a[i1]){
			box[cnt].second=1;
			flg=1;
		}
		if(flg==0){
			box[cnt].second=0;
		}
		cnt++;
	}
	}
	sort(box,box+cnt+1);
	sima=1;
	MAX=0;
	for(i=0;i<=cnt;i++){
		sima=sima+box[i].second;
		if(sima>MAX){
			MAX=sima;
		}
	}
	printf("%d\n",MAX);
	return 0;
}


Measured memory_bytes: 3924