akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
void solve(){
    int a,b,x;
    cin >> a >> b >> x;
    // a + b / 
    if(a + b >= x && a <= x) {
        cout << "YES";
    }    
    else {
        cout << "NO";
    }
}
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#undef max
#undef min

std::array<std::vector<long long>, 40001> vLine;

struct Point {
	long long x, y;
};

int main() {
	int n;
	while (std::cin >> n && n) {
		Point curtain[2];

		for (auto& line : vLine) {
			line.clear();
		}

		int lx = 99999, ly = 99999;
		int firstX, firstY;
		for (int i = 0; i < n + 1; i++) {
			int x, y;
			if (i != n) {
				std::cin >> x >> y;
				x += 20000;
				y += 20000;
			}
			else {
				x = firstX;
				y = firstY;
			}
			if (!i) {
				firstX = x; firstY = y;
			}
			if (i) {
				for (int j = std::min(y, ly); j < std::max(y, ly); j++) {
					vLine[j].push_back(x);
				}
			}
			lx = x;
			ly = y;
		}
		int a[4], b[4];
		for (int i = 0; i < 4; i++) {
			std::cin >> a[i] >> b[i];
			a[i] += 20000;
			b[i] += 20000;
		}
		curtain[0] = { *(std::min_element(a, &a[3])), *(std::max_element(b, &b[3])) }; // 左上
		curtain[1] = { *(std::max_element(a, &a[3])), *(std::min_element(b, &b[3])) }; // 右下

		// 下からスキャン
		long long sum = 0;
		for (int y = 0; y < 40000; y++) {
			if (vLine[y].empty()) continue;

			std::sort(vLine[y].begin(), vLine[y].end());
			int lx = 0;
			for (int i = 0; i < vLine[y].size(); i++) {
				long long x = vLine[y][i];
				if (i % 2) {
					if (y >= curtain[0].y || curtain[1].y > y || curtain[1].x <= lx || curtain[0].x >= x) sum += x - lx; // 露出している
					else if (curtain[0].x <= lx && x <= curtain[1].x); // 隠れている
					else { //中途半端
						if (lx <= curtain[0].x && curtain[1].x <= x) {
							sum += (x - lx) - (curtain[1].x - curtain[0].x);
						}
						else if (curtain[0].x < x && x <= curtain[1].x) { // 右が隠れている
							sum += curtain[0].x - lx;
						}
						else { // 左が隠れている
							sum += x - curtain[1].x;
						}
					}
				}
				lx = x;
			}
		}
		std::cout << sum << std::endl;
	}
	return 0;
}


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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int foodNum;
    cin >> foodNum;
    int order[foodNum], point[foodNum], extra[foodNum - 1];
    
    for(int i = 0; i < foodNum; i++) cin >> order[i];
    for(int i = 0; i < foodNum; i++) cin >> point[i];
    for(int i = 0; i < foodNum - 1; i++) cin >> extra[i];
    
    int total = 0;
    for(int i = 0; i < foodNum; i++){
        total += point[i];
        if(i != 0 && (order[i] - order[i - 1] == 1)) total += extra[order[i] - 2];
    }
    cout << total;
    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';

const int N = 51;
int dp[N][N * N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif

    dp[0][0] = 1;
    int n, A;
    cin >> n >> A;
    vector <int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    for (auto e : a) {
        for (int i = n - 1; i >= 0; --i) {
            for (int j = 0; j < N * N; ++j) {
                if (dp[i][j]) {
                    dp[i + 1][j + e] += dp[i][j];
                }   
            }   
        }   
    }   

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += dp[i][i * A];        
    }                       
    cout << ans << endl;
}


Measured memory_bytes: 4036
#include<stdio.h>

int main(){
	int n,m,a[101][101]={0},b[101]={0},c[101]={0};
    int i,j;
	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			c[i]+=a[i][j]*b[j];
		}
		printf("%d\n",c[i]);
	}
	
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>

using namespace std;

int main()
{
    long long int s=0,r1,r2;
    cin>>r1>>r2;
    if(r1==1)
    s+=300000;
    if(r1==2)
    s+=200000;
    if(r1==3)
    s+=100000;
    if(r2==1)
    s+=300000;
    if(r2==2)
    s+=200000;
    if(r2==3)
    s+=100000;
    if(r1==1 &&r2==1)
    s+=400000;    
    
    cout<<s;
    
 
   return 0;
}


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

int main() {
  int p,q,r;
  cin >> p >> q >> r;
  int ans = p + q + r - max(p,max(q,r));
  cout << ans << endl;
  return 0;
}


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

int main(){
  int d,n,m;

  while(cin >> d ,d){
    vector<int> cu,sh;
    int c,s;
    sh.push_back(0);

    cin >> n >> m;
    for(int i = 1 ; i < n ; i++){
      cin >> s;
      sh.push_back(s);
    }
    sh.push_back(d);
    for(int i = 0 ; i < m ; i++){
      cin >> c;
      cu.push_back(c);
    }

    int sum = 0;  
    sort(sh.begin(),sh.end());
    sort(cu.begin(),cu.end());
    int pos = 1;
    for(int i = 0 ; i < m ; ){
      if(sh[pos] >= cu[i]){
	sum += min(sh[pos]-cu[i],cu[i]-sh[pos-1]);
	i++;
      }
      else ++pos;
    }
    cout << sum << endl;
  }

  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;


string str;

int main(){
    cin>>str;
    int counter=0,counter2=0;
    rep(i,str.length()){
        if(i%2==0 && str.substr(i,1)=="1")counter++;
        else if(i%2==1 && str.substr(i,1)=="0")counter++;
    }
    rep(i,str.length()){
        if(i%2==0 && str.substr(i,1)=="0")counter2++;
        else if(i%2==1 && str.substr(i,1)=="1")counter2++;
    }
    cout<<min(counter,counter2)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n, m;
  cin >> n >> m;
  int a = 0, b = 0;
  vi has(n + 1), other(n + 1);
  while(m--){
    int x;
    cin >> x;
    string s;
    cin >> s;
    if(s == "WA"){
      if(!has[x]) other[x]++;
    }
    else{
      if(!has[x]) a++, has[x] = 1;
    }
  }
  for(int i = 0; i <= n; i++){
    if(has[i]) b += other[i];
  }
  cout << a << " " << b;
}

Measured memory_bytes: 1024
# encoding: utf-8
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]


tab = [0] * (H * W)

for i in range(H):
    for j in range(W):
        idx = i * W + j
        if i == j == 0: tab[idx] = 1
        elif a[i][j] == '#': continue
        elif i == 0: tab[idx] = tab[idx - 1]
        elif j == 0: tab[idx] = tab[idx - W]
        else:
            tab[idx] = (tab[idx - 1] + tab[idx - W]) % (10 ** 9 + 7)

print(tab[-1])

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    string S;
    cin >> S;
    scanLLInt(K);
    int x = 0;
    char n = '1';
    for (auto& c : S){
        if (c != '1'){
            n = c;
            break;
        }
        ++x;
    }
    if (K < x + 1){
        cout << "1" << endl;
    }else{
        cout << n << endl;
    }
}

Measured memory_bytes: 256
program prob1
    implicit none
    character(1)::b
    read(*,*) b
    if(b .eq. 'A') then
        write(*,'(a)') 'T'
    else if(b .eq. 'T') then
        write(*,'(a)') 'A'
    else if(b .eq. 'C') then
        write(*,'(a)') 'G'
    else
        write(*,'(a)') 'C'
    end if
    stop
end program

Measured memory_bytes: 2900
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;
	int a[n + 5];
	int sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
	}
	int than;
	if(sum % (4 * m) == 0) than = sum / (4 * m);
	else than = sum / (4 * m) + 1;
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] >= than) cnt++;
	}
	if(cnt >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
let binom_memo ( *^ ) ( /^ ) n =
  let i = ref 0 in
  let a = Array.make (n / 2 + 1) 1 in
  let rec binom_memo_aux k =
    if k <= !i
    then a.(k)
    else begin
      incr i;
      a.(!i) <- a.(!i - 1) *^ (n - !i + 1) /^ !i;
      binom_memo_aux k
    end in
  fun k -> binom_memo_aux (min k (n - k))

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 998244353
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m
let ( /^ ) x y = power ( *^ ) x y (m - 2)

let () = Scanf.scanf "%d %d %d" @@ fun n m k ->
  let binom = binom_memo ( *^ ) ( /^ ) (n - 1) in
  Printf.printf "%d\n" @@
  List.fold_left ( +^ ) 0 @@
  List.init (k + 1) @@ fun k ->
    power ( *^ ) (m *^ binom k) (m - 1) (n - 1 - k)



Measured memory_bytes: 15356
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll dp[200][100001];
int S[200];
int main() {
	int N, X;
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	sort(S, S + N);
	for (int i = 0; i <= X; i++) {
		dp[0][i] = i % S[0];
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j <= X; j++) {
			(dp[i][j] += dp[i - 1][j%S[i]]) %= MOD;
			(dp[i][j] += (i*dp[i - 1][j]) % MOD) %= MOD;
		}
	}
	cout << dp[N - 1][X] << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
const int NMAX = 100005;
vector<pll> graph[NMAX];
bool check[NMAX];
ll dist[NMAX];

void dfs(ll now){
    check[now] = true;
    REP(i, graph[now].size()){
        ll next = graph[now][i].first;
        ll cost = graph[now][i].second;
        if(check[next]==false){
            dist[next] = dist[now] + cost;
            dfs(next);
        }
    }
}

int main(){
    int N;
    cin >> N;
    REP(i, N-1){
        ll a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        graph[a].push_back(make_pair(b, c));
        graph[b].push_back(make_pair(a, c));
    }
    REP(i, N){
        check[i] = false;
        dist[i] = 0;
    }
    ll Q, K;
    cin >> Q >> K;
    dfs(K-1);
    REP(i, Q){
        ll x, y;
        cin >> x >> y;
        x--;y--;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}

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

int main(){
    int n;
    scanf("%d", &n);
    char t[n];
    scanf("%s",t);

    int i = 0;
    int j = 0;
    while(i < n - 2){
        if(t[i] == 'A' && t[i+1] == 'B' && t[i+2] == 'C'){
            j++;
        }
        i++;
    }
    printf("%d", j);
}



Measured memory_bytes: 256
N = int(input())
B_list = list(map(int,input().split()))
#A_list = [0 for i in range(N)]

sum_aaa = B_list[0]

for i in range(1,N-1):
    sum_aaa += min(B_list[i],B_list[i-1])

sum_aaa += B_list[-1]
print(sum_aaa)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
using namespace std;

main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e = (c*d)/__gcd(c, d),
        cnt_a = (a-1)/c + (a-1)/d - (a-1)/e,
        cnt_b = b/c + b/d - b/e;
    cout << b-a+1-cnt_b+cnt_a;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIII pair< int, pair<int,int> >
const int MXN = 1e5+5;
int a[MXN][4], dp[MXN][4];
int N;

int rec(int pos, int type){

    if(pos>N) return 0;

    if(dp[pos][type]!=-1) return dp[pos][type];

    int ret = -1;
    for(int i=1; i<=3; i++)
        if(i!=type)
            ret = max (ret, rec(pos+1,i) + a[pos+1][i]);

    return dp[pos][type] = ret;
}

void read(){

    int i,j;
    cin>>N;
    for(i=1; i<=N; i++)
        for(j=1; j<=3; j++)
            cin>>a[i][j];
}

void solve(){

    memset(dp,-1,sizeof(dp));
    read();
    cout<< rec(0,0) << "\n";
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}


Measured memory_bytes: 9600
N = int(input())
h = [*map(lambda x: int(x), input().split())]

#bottom-up

def iterative_method(final):
    i = 0
    min_table = {0: 0}

    while (i < final):
        if i+1 in min_table:
            min_table[i+1] =  min(min_table[i+1], min_table[i] + abs(h[i+1] - h[i]))
        else:
            min_table[i+1] = min_table[i] + abs(h[i+1] - h[i])
        try:
            if i+2 in min_table:
                min_table[i+2] = min(min_table[i+2], min_table[i] + abs(h[i+2] - h[i]))
            else:
                min_table[i+2] = min_table[i] + abs(h[i+2] - h[i])
        except:
            break
        i += 1


    print(min_table[final])

iterative_method(N-1)

Measured memory_bytes: 27040
#include <iostream>
#include <utility>
#define N 	100

using namespace std;

int T[N+1][N+1];
pair<int , int> M[N+1];
int t = 0;

void init(){
	for (int i = 0; i < 100; ++i)
	{
		M[i].first = 0;
		M[i].second = 0;
		for (int j = 0; j < 100; ++j)
		{
			T[i][j] = 0;
		}
	}
}

void DispTable(int n){
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			cout << T[i][j];
			if(j!=n) cout << " ";
		}
		cout << endl;
	}
}

void DispM(int n){
	for (int i = 1; i<=n; i++)
	{
		cout << i << " " << M[i].first << " " << M[i].second << endl;
	}
}

void dfs(int cur,int n){
	t++;
	M[cur].first = t;
	// cerr << "visiting " << cur << " " << t << endl;
	for (int i = 1; i <= n; ++i)
	{
		if(T[cur][i] == 1 && M[i].first == 0) dfs(i,n);
	}
	t++;
	M[cur].second = t;
}

int main(){
	int n;
	cin >> n;
	init();
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int v;
			cin >> v;
			T[u][v] = 1;	
		}
	}
	// DispTable(n);
	dfs(1,n);
	for (int i = 2; i <= n; ++i)
	{
		if(M[i].first==0) dfs(i,n);
	}
	DispM(n);
	return 0;
}

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

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

int main(){
	int x[5];
	rep(i,5) cin >> x[i];
	rep(i,5){
		if(x[i]==0){
			cout << i+1 << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    long long int a,b,c;
    cin>>a>>b>>c;
    long long int ret  =b/c;
    long long int ret2 = max(0LL,a-1LL)/c;
    if (a==0) {
        ret++;

    }
    ret-=ret2;
    cout<<ret<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

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


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

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

    if(a <= c && c <= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n;
    string s[110];
    cin>>n;
    bool ok=1;
    for(int i=0;i<n;i++){
	cin>>s[i];
	for(int j=0;j<i;j++)if(s[i]==s[j])ok=0;
    }
    for(int i=0;i<n-1;i++){
	if(s[i].back()!=s[i+1][0])ok=0;
    }
    cout<<(ok?"Yes":"No")<<endl;
}




Measured memory_bytes: 256
let (n1, n2, n_limit) = (3, 9, 31)

let area =
  [| [1; 3]; [0; 2; 4]; [1; 5]
   ; [0; 4; 6]; [1; 3; 5; 7]; [2; 4; 8]
   ; [3; 7]; [4; 6; 8]; [5; 7] |]

let goal = Array.init n2 (fun i -> (i + 1) mod n2)

let md = Array.make_matrix n2 n2 0

let initialize_md () =
  for i = 0 to n2 - 2 do
    for j = 0 to n2 - 1 do
      md.(i+1).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done

let idastar a limit space lower =
  let rec doit i space moved lower =
    if i = limit then
      if a <> goal then ()
      else begin
        List.length moved - 1 |> Printf.printf "%d\n";
        exit 0;
      end
    else
      List.iter (fun j ->
        let x = a.(j) in
        if x = List.hd moved then () else
        let lower = lower - md.(x).(j) + md.(x).(space) in
        if lower + i > limit then ()
        else begin
          a.(j) <- 0;
          a.(space) <- x;
          doit (i + 1) j (x :: moved) lower;
          a.(j) <- x;
          a.(space) <- 0;
        end) area.(space) in
  doit 0 space [-1] lower

let findi a x =
  let n = Array.length a in
  let rec doit i =
    if i = n then assert false
    else if a.(i) = x then i
    else doit (i + 1) in
  doit 0

let () =
  initialize_md ();
  let a = Array.init n2 (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let space = findi a 0 in
  let lower =
    Array.fold_left (fun (i, sum) e -> (i + 1, sum + md.(e).(i))) (0, 0) a |> snd in
  for limit = lower to n_limit do
    idastar a limit space lower
  done

Measured memory_bytes: 4320
using System;

namespace AtCorderA
{
    public class Program
    {
        public static void Main(string[] args)
        {
        	var input = Console.ReadLine();
        	var inputList = input.Split(" ");
          	int.TryParse(inputList[0], out var h1);
          	int.TryParse(inputList[1], out var m1);
          	int.TryParse(inputList[2], out var h2);
          	int.TryParse(inputList[3], out var m2);
          	int.TryParse(inputList[4], out var k);
          
          	var wakeUpMinutes = (h2 - h1) * 60 + (m2 - m1);
          	Console.WriteLine(wakeUpMinutes - k);
        }
    }
}

Measured memory_bytes: 27544
n=int(input())
T='abcdefghijklmnopqrstuvwxyz'
s=''
while n>0:
    sn=n%26
    if sn>0:
        s=T[sn-1]+s
        n//=26
    else:
        s=T[25]+s

        n=n//26-1

print(s)

Measured memory_bytes: 9164
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
int main()
{
//	freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	int n,m,minv=1e4,first,last,i,j;
	cin>>n>>m;
	first=n%2019;
	last=m%2019;
	if(m-n>=2019)
	    last+=2019;
	for(i=first;i<=last;i++)
		for(j=i+1;j<=last;j++)
		{
			if(i%2019==0||j%2019==0)
			{
				cout<<0;
				return 0;
			}
		    minv=min(minv,i*j%2019);	
		}
	cout<<minv;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
dic = defaultdict(lambda: 0)

for _ in range(n):
    judge = input()
    dic[judge] += 1

print(f"AC x {dic['AC']}")
print(f"WA x {dic['WA']}")
print(f"TLE x {dic['TLE']}")
print(f"RE x {dic['RE']}")

Measured memory_bytes: 9472
#include<stdio.h>
#define abs(arg) ((arg)<0?-(arg):(arg))

int main(void){
    register int i,j;
    int n,m;
    scanf("%d%d",&n,&m);
    long a[n],b[n],c[m],d[m];
    for(i = 0;i < n;++i)scanf("%ld%ld",&a[i],&b[i]);
    for(i = 0;i < m;++i)scanf("%ld%ld",&c[i],&d[i]);
    unsigned long mindist[n],minchptr[n];
    for(i = 0;i < n;++i){
        mindist[i] = 400000001;
        for(j = m-1;j >= 0;--j){
            unsigned long curdist = abs(a[i] - c[j])+abs(b[i] - d[j]);
            if(curdist <= mindist[i]){
                mindist[i] = curdist;
                minchptr[i] = j;
            }
        }
    }
    for(i = 0;i < n;++i)printf("%ld\n",minchptr[i]+1);
}

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

using namespace std;

#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl

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


int main() {
    ll n,w;
    cin>>n>>w;
	pair<ll,ll> p[n];
	for(ll i=0;i<n;i++)
	cin>>p[i].ff>>p[i].ss;
	sort(p,p+n);
	ll dp[n+1][w+1]={0};
	for(ll i=0;i<n+1;i++)
	{
	    for(ll j=0;j<=w;j++)
	    {
	        if(i==0)
	        dp[i][j]=0;
	        else if(j==0)
	        dp[i][j]=0;
	        else if(j>=p[i-1].ff)
	        {
	            //if(dp[i][j-p[i-1].ff]==dp[i-1][j-p[i-1].ff])
	            dp[i][j]=max(dp[i-1][j],p[i-1].ss+dp[i-1][j-p[i-1].ff]);
	       }
	        else
	        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	    }
	}
	cout<<dp[n][w];
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
	
	cin>>a;
	cin>>b;
	int len=a.length();
	int cnt=0;
	for(int i=0;i<len;i++)
	{
		if(a[i]!=b[i])
		cnt++;
	}
	cout<<cnt<<endl; 
	
	return 0;
	
} 

Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000

int fun(int n) {
    if (n % 2 == 0) return n / 2;
    else return 3 * n + 1;
}

int main() {
    int s, i = 0;
    cin >> s;
    vector<int> bucket(MAX);
    vector<int> seq_a(MAX);
    seq_a.at(i) = s;
    bucket.at(seq_a.at(i))++;
    while (1) {
        i++;
        seq_a.at(i) = fun(seq_a.at(i - 1));
        bucket.at(seq_a.at(i))++;
        if (bucket.at(seq_a.at(i)) > 1) {
            cout << i + 1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 8064
using System;
using System.Collections.Generic;
using System.Linq;

class Program{

  static int h, w;
  static bool yn = true;

  static int Main() {

    string[] nyu = new string[2];

    nyu = Console.ReadLine().Split(' ');
    h = int.Parse(nyu[0]);
    w = int.Parse(nyu[1]);

    char[] nya = new char[w];
    int[,] s = new int[h+2, w+2];

    for (int i = 0; i <= h + 1; i ++) {
      s[i, 0] = 0;
      s[i, w+1] = 0;
    }
    for (int i = 1; i <= w ; i ++) {
      s[0, i] = 0;
      s[h+1, i] = 0;
    }

    for (int i = 1; i <= h; i ++) {
      string nyo = Console.ReadLine();
      for(int l = 0; l < w; l++){
        nya[l] = nyo[l];
      }

      for (int j = 1; j <= w; j++) {
        if (nya[j-1] == '.') {
          s[i, j] = 0;
        } else {
          s[i, j] = 1;
        }
      }
    }

    for (int i = 1; i <= h; i ++) {
      for (int j = 1; j <= w; j++) {
        if (s[i, j] == 1 && s[i-1, j] + s[i+1, j] + s[i, j-1] + s[i, j+1] == 0) {
          yn = false;
          break;
        }
      }
    }

    if (yn) Console.WriteLine("Yes"); else Console.Write("No");

    return 0;
  }

}


Measured memory_bytes: 13120
base1 = 127
base2 = 1009
mask = (1 << 32) - 1


def calc_hash(f, r, c):
    global ph, pw, h
    tmp = [[0] * c for _ in range(r)]
    dr, dc = r - ph, c - pw

    t1 = 1
    for _ in range(pw):
        t1 = (t1 * base1) & mask
    for i in range(r):
        e = 0
        for j in range(pw):
            e = e * base1 + f[i][j]
        for j in range(dc):
            tmp[i][j] = e
            e = (e * base1 - t1 * f[i][j] + f[i][j + pw]) & mask
        tmp[i][dc] = e

    t2 = 1
    for _ in range(ph):
        t2 = (t2 * base2) & mask
    for j in range(dc + 1):
        e = 0
        for i in range(ph):
            e = e * base2 + tmp[i][j]
        for i in range(dr):
            h[i][j] = e
            e = (e * base2 - t2 * tmp[i][j] + tmp[i + ph][j]) & mask
        h[dr][j] = e


th, tw = map(int, input().split())
t = [[ord(c) for c in input().strip()] for _ in range(th)]
ph, pw = map(int, input().split())
p = [[ord(c) for c in input().strip()] for _ in range(ph)]

if th >= ph and tw >= pw:
    h = [[0] * tw for _ in range(th)]
    calc_hash(p, ph, pw)
    key = h[0][0] & mask
    calc_hash(t, th, tw)
    for i in range(th - ph + 1):
        for j in range(tw - pw + 1):
            if h[i][j] & mask == key:
                print(i, j)

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

int main(int argc, char const *argv[])
{
	int n, k; cin >> n >> k;
	vector<int> h(n); rep(i, n) cin >> h[i];
	sort(h.begin(), h.end());
	ll ans = 0;
	rep(i, max(0, n - k)) {
		ans += h[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " is " << (x) << "\n"
#define ll long long int
#define ld long double
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll powmod(ll a, ll b){
	ll res = 1ll;
	while(b){
		if(b%2 == 1)	res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

bool comp(pair<int, int> a, pair<int, int> b){
	return a.first < b.first or (a.first == b.first and a.second > b.second);
}

int main(){

 
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;

	pair<int, int> arr[n];
	int a = 0, b = 0;
	for(int i = 0; i < n; i++)	{
		cin >> arr[i].first >> arr[i].second;

		if(arr[i].first > arr[a].first)	a = i;
		if(arr[i].second < arr[b].second)	b = i;
	}

	ll ans = max(0, 1 + arr[b].second - arr[a].first), tmp = 0;
	for(int i = 0; i < n; i++){
		if(i == a or i == b)	continue;
		tmp = max((int)tmp, 1 + arr[i].second - arr[i].first);
	}	

	ans += tmp;
	vector<pair<int, int>> vec;

	for(int i = 0; i < n; i++){
		if(i == a or i == b)	continue;
		int x = arr[i].first, y = arr[i].second;
		vec.push_back({max(0, y - arr[a].first + 1), max(0, 1 + arr[b].second - x)});
	}
	n = vec.size();

	if(n == 0 and a != b){
		cout << arr[a].second - arr[a].first + arr[b].second - arr[b].first + 2 << "\n";
		return 0;
	}
	if(!n or a == b){
		cout << ans << "\n";
		return 0;
	}

	sort(vec.begin(), vec.end(), comp);
	
	ans = max((int)ans, vec[0].first + arr[b].second + 1 - arr[b].first);
	int res = (int)2e9;
	vec.push_back({arr[a].second - arr[a].first + 1, 0});
	
	for(int i = 0; i < n; i++){
		res = min(res, vec[i].second);
		ans = max((int)ans, res + vec[i+1].first);
	}

	cout << ans;
}

Measured memory_bytes: 2168
;キュー使用版
(defvar hd '(1 2 3 4 5 6 7 8 9))
(defvar tl (nthcdr 8 hd))

(defun enqueue (N)
  (rplacd tl (list N))
  (setf tl (cdr tl)))

(loop with x and y
      repeat (read) do
      (setf x (pop hd)
            y (mod x 10))
      (if (/= 0 y) (enqueue (+ (* 10 x) y -1)))
      (enqueue (+ (* 10 x) y))
      (if (/= 9 y) (enqueue (+ (* 10 x) y +1)))
      finally (princ x))

Measured memory_bytes: 15972
# your code goes here
loop do
	line = gets
	if line == nil
		break	
	end
	words = line.split(" ")
	w_length = words.length
	
	offset = 0
	26.times do |index|
		# the, this, that
		t = (("t".ord - "a".ord + index) % 26 + "a".ord).chr
		h = (("h".ord - "a".ord + index) % 26 + "a".ord).chr
		e = (("e".ord - "a".ord + index) % 26 + "a".ord).chr
		i = (("i".ord - "a".ord + index) % 26 + "a".ord).chr
		a = (("a".ord - "a".ord + index) % 26 + "a".ord).chr
		s = (("s".ord - "a".ord + index) % 26 + "a".ord).chr
	
	#	p [t+h+e, t+h+i+s, t+h+a+t]
	#	p words - [t+h+e, t+h+i+s, t+h+a+t]
		if (words - [t+h+e, t+h+i+s, t+h+a+t]).length < w_length
			offset = index
			break
		end
	end
	
	puts line.chars.map{|s| (97 <= s.ord && s.ord <= 122)?((s.ord - 71 - offset) % 26 + 97).chr():s}.inject(:+)
end

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> per(n);
  for (int i = 0; i < n; i++) per[i] = i;
  vector<double> dist;
  int cnt = 0;
  do {
    double d = 0;
    cnt++;
    for (int i = 0; i < n - 1; i++) {
      d += sqrt((x[per[i + 1]] - x[per[i]]) * (x[per[i + 1]] - x[per[i]]) +
                (y[per[i + 1]] - y[per[i]]) * (y[per[i + 1]] - y[per[i]]));
    }
    dist.emplace_back(d);
  } while (next_permutation(per.begin(), per.end()));
  double ans = 0;
  for (const auto& d : dist) {
    ans += d;
  }
  ans /= cnt;
  cout << fixed << setprecision(17) << ans << '\n';
  return 0;
}


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

using ll = long long;
using P = pair<int, int>;

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

int main() {
  ll K, A, B;
  cin >> K >> A >> B;

  if (A + 2 > B) {
    cout << K + 1 << endl;
    return 0;
  }

  if (K <= A) {
    cout << K + 1 << endl;
    return 0;
  }

  // B枚を取得するための1連の操作
  K -= A + 1;
  ll ans = B;
  // A枚を1円に交換、B枚を取得の操作を繰り返す
  ans += (B - A) * (K / 2);
  K %= 2;

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


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

string s;
int x, y;

short a[4010][2][8010];

vector<int> ido[2];

bool dp1(int i, int j){
    if(i == ido[0].size()){
        if(j == x){
            return true;
        }
        return false;
    }

    if(a[i][j >= 0][abs(j)] != -1){
        return a[i][j >= 0][abs(j)];
    }

    if(i == 0){
        return a[i][j >= 0][abs(j)] = dp1(i+1, j+ido[0][i]);
    }else{
        return a[i][j >= 0][abs(j)] = dp1(i+1, j+ido[0][i]) || dp1(i+1, j-ido[0][i]);
    }
}

bool dp2(int i, int j){
    if(i == ido[1].size()){
        if(j == y){
            return true;
        }
        return false;
    }

    if(a[i][j >= 0][abs(j)] != -1){
        return a[i][j >= 0][abs(j)];
    }

    return a[i][j >= 0][abs(j)] = dp2(i+1, j+ido[1][i]) || dp2(i+1, j-ido[1][i]);
}

int main(){
    cin >> s;
    cin >> x >> y;

    int tmp = 0;
    int nakamura = 0;

    for(int i = 0;i < s.size();i++){
        if(s[i] == 'F'){
            tmp++;
        }else{
            ido[nakamura].push_back(tmp);
            nakamura = (nakamura + 1) & 1;
            tmp = 0;
        }
    }

    ido[nakamura].push_back(tmp);

    memset(a, -1, sizeof(a));
    if(dp1(0, 0)){
        memset(a, -1, sizeof(a));
        if(dp2(0, 0)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 125952
n = gets.to_s.to_i
s = gets.to_s.chomp
 
r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r * g * b
n.times do |j|
  
  (1...n).each do |t|
    i = j - t
    k = j + t
    break if i < 0 || n - 1 < k
    ans -= 1 if s[i] != s[j] && s[j] != s[k] && s[k] != s[i]
  end
end

puts ans


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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

vector<int> v;
vector<int> p;

int prnum(int l,int r){
  vector<int>::iterator it1 = lower_bound(v.begin(),v.end(),l);
  vector<int>::iterator it2 = lower_bound(v.begin(),v.end(),r);
  int mask=0;
  if(*it2==r)
    mask++;
  return distance(v.begin(),it2)-distance(v.begin(),it1)+mask;
}

bool ismyprime(int k){
  bool bl=true;
  int j=0;
  while(j+1<p.size() && p[j]*p[j]<=k){
    if(k%p[j]==0)
      bl=false;
    j++;
  }
  if(bl)
    p.push_back(k);
  if(k%2==0)
    return false;
  REP(i,v.size()){
    if(k%p[i]==0 || ((k+1)/2)%p[i]==0){
      return false;
    }
  }
  return true;
}

int main(){
  p.push_back(2);
  p.push_back(3);
  v.push_back(3);
  FOR(i,4,100001){
    if(i%2!=0 && ismyprime(i))
      v.push_back(i);
  }
  int q,l,r;
  cin>>q;
  REP(i,q){
    cin>>l>>r;
    cout<<prnum(l,r)<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 768
def division(array, base, num):
    for i in range(num):
        if array[i] % base != 0:
            return False
    return True


num = int(input())
array = list(map(int, input().split()))

count = 0
base = 2
while division(array, base, num):
    base *= 2
    count += 1

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,s[100],ave,flag1,flag2;
  bool a,b;
  while(cin >>n && n!=0){
    a=false;b=false;
    flag1=0;flag2=0;
    ave=0;
    for(int i=0;i<n;i++) cin >>s[i];
    sort(s,s+n);

    if(s[0]==s[1]){
      a=true;
    for(int i=1;i<n;i++){
      if(s[0]==s[i]){
	flag1++;
	s[i]=0;}
      else break;
    }
    }
    else if(s[0]==s[1])
    if(s[n-1]==s[n-2]){
	b=true;
    for(int i=n-2;i>=0;i--){
      if(s[n-1]==s[i]){
	flag2++;
	s[i]=0;}
      else  break;
    }
    }

  for(int i=1;i<n-1;i++) ave+=s[i];
  if(a==true){
    n-=flag1;
    ave+=s[0];}
    else n-=1;
  if(b==true){
    n-=flag2;
    ave+=s[n-1];}
    else n-=1;
    ave/=n;
    cout <<ave<<endl;
  }
}

Measured memory_bytes: 1176
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		int[][] map = new int[10][10];
		
		int ink[][][] =
			{
				{
					{0,0,0,0,0},
					{0,0,1,0,0},
					{0,1,1,1,0},
					{0,0,1,0,0},
					{0,0,0,0,0},		
				},
				{
					{0,0,0,0,0},
					{0,1,1,1,0},
					{0,1,1,1,0},
					{0,1,1,1,0},
					{0,0,0,0,0},		
				},
				{
					{0,0,1,0,0},
					{0,1,1,1,0},
					{1,1,1,1,1},
					{0,1,1,1,0},
					{0,0,1,0,0},
				}
			};
		
		Scanner scanner = new Scanner(System.in);
		for(; scanner.hasNext();)
		{
			String str = scanner.next();
			String[] num = str.split(",");
			
			int x = Integer.parseInt(num[0]);
			int y = Integer.parseInt(num[1]);
			int id = Integer.parseInt(num[2]) -1;
			
			for(int i=0; i<5; i++)
			{
				for(int j=0; j<5; j++)
				{
					int px = x-2+i;
					int py = y-2+j;
					if((0<=px && px<10) && (0<=py && py<10))
					{
						map[px][py] += ink[id][i][j];
					}
					
				}
			}
		}
		
		int count = 0;
		int max = 0;
		for(int i=0; i<10; i++)
		{
			for(int j=0; j<10; j++)
			{
				if(map[i][j] == 0)
				{
					count ++;
				}
				else if(map[i][j] > max)
				{
					max = map[i][j];
				}
			}
		}
		
		System.out.println(count);
		System.out.println(max);
	}
}

Measured memory_bytes: 26220
public class Main {

	public static void main(String[] args) {
		int num = new java.util.Scanner(System.in).nextInt()%10;
		int[] hon = {2,4,5,7,9};
		int[] pon = {0,1,6,8};
		int bon = 3;
		int times = hon.length+pon.length;
		for ( int i=0 ; i<times ; i++ ) {
			if ( num == hon[i]) {
				System.out.println("hon");
				break;
			} else if ( num == pon[i] ) {
				System.out.println("pon");
				break;
			} else if ( num == bon ) {
				System.out.println("bon");
				break;
			}
		}
	}

}


Measured memory_bytes: 35588
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        System.out.println(solve(N, K));
    }

    private static int solve(int N, int K) {
        StringBuilder sb = new StringBuilder();

        while (N > 0) {
            int val = N%K;

            sb.append(val);
            N /= K;
        }

        return sb.reverse().toString().length();
    }
}

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

void Main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum += p[i];
    }
    
    cout << sum << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

int main() {
  int A = 0, B = 0, N = 0;
  cin >> N >> A >> B;
  
  int p1 = N * A;
  int p2 = B;
  if (p1 > p2) {
    cout << p2 << endl;
  } else {
    cout << p1 << endl;
  }
}

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

int main()
{
  char a[110], b[110];
  bool greater=false;
  bool less=false;
  cin >> a >> b;

  if(strlen(a)>strlen(b)) greater=true;
  else if(strlen(a)<strlen(b)) less=true;
  else{
    for(int i=0;i<strlen(a);i++){
      int aa=a[i]-48;
      int bb=b[i]-48;
      if(aa > bb) {
        greater = true;
        break;
      }
      else if(aa<bb){
        less=true;
        break;
      }
    }
  }

  if(greater) cout << "GREATER" << endl;
  else if(less) cout << "LESS" << endl;
  else cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
    ll a,b,x,min,max,c=0;
    cin>>a>>b>>x;
    max=b/x;
    if(a%x==0)
        min=a/x;
    else
        min=a/x+1;
    cout<<max-min+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
int main(){
    string b;
    cin>>b;
    if(b[0]=='A')cout<<'T';
    if(b[0]=='T')cout<<'A';
    if(b[0]=='G')cout<<'C';
    if(b[0]=='C')cout<<'G';
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

long long discrete_binary_search(long long ok, long long ng, const std::function<bool(long long)> &check) {
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    return ok;
}

int Q;
int A[110], B[110];
signed main() {
    cin >> Q;
    rep(i, Q) {
        cin >> A[i] >> B[i];
        if (A[i] > B[i]) { swap(A[i], B[i]); }
        cout << 2 * (A[i] - 1) + discrete_binary_search(0, B[i] - A[i] + 1, [&](int x) {
            return (A[i] + x / 2) * (A[i] + (x + 1) / 2) < A[i] * B[i];
        }) << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 500000

void buildMaxHeap(int *);
void maxHeapify(int *, int);

int H;
int A[MAX+1];

int main(){
  int i, j;

  scanf("%d",&H);

  for(i=1; i<=H; i++){
    scanf("%d",&A[i]);
  }

  buildMaxHeap(A);

  for(j=1; j<=H; j++){
    printf(" %d", A[j]);
  }
  printf("\n");

  return 0;
}

void buildMaxHeap(int *A){
  int i;
  for(i=H/2; i>=1; i--){
    maxHeapify(A, i);
  }
}

void maxHeapify(int *A, int i){
  int l=2*i, r=2*i+1;
  int largest, tem;

  if(l <= H && A[l] > A[i]) largest=l;
  else largest=i;
  if(r <= H && A[r] > A[largest]) largest=r;

  if(largest != i){
    tem=A[i];
    A[i]=A[largest];
    A[largest]=tem;
    maxHeapify(A, largest);
  }
}


  
  
  



Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;

vector<int> adj[100010];
int dp[100010];

int dfs(int v)
{
	if (~dp[v]) return dp[v];
	int res = 0;
	for (int nv : adj[v])
	{
		res = max(dfs(nv)+1, res);
	}
	return dp[v] = res;
}

void solve()
{
	int N, M;
	cin >> N >> M;

	for (int i = 0; i < M; i++)
	{
		int x, y;
		cin >> x >> y;
		adj[x-1].push_back(y-1);
	}

	memset(dp, -1, sizeof(dp));

	int ans = 0;

	for (int n = 0; n < N; n++)
	{
		ans = max(ans, dfs(n));
	}

	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << '\n'
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << '\n'
#define space ' '
#define enter '\n'
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 204001, mod = 1e9 + 7;
 int n;
 void Fakemain( )
 {
  IOS;
  cin >> n;
  cout << ( n >= 30 ? "Yes" : "No" );
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 3608
count = 0 
n,m,c = list(map(int,input().split()))
b_lis = list(map(int,input().split()))
for i in range(n):
    a_lis = list(map(int,input().split()))
    sums = 0
    for i in range(m):
        sums += b_lis[i]*a_lis[i]
    if sums + c >0:
        count +=1
print(count)

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

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

	int q; cin >> q;

	for (int i = 0; i < q; i++) {
		int b,e,k;
		cin >> b >> e >> k;
		int cnt=0;
		for (int i = b; i < e; i++) {
			if(a[i]==k) cnt++;
		}
		cout << cnt << endl;
	}

}
	



Measured memory_bytes: 3104
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
# print(factorial(N))
ans = 0
for i in range(1, N + 1):
    ans += i
print(ans)

Measured memory_bytes: 5700
#include <iostream>
#include <cmath>

using namespace std;

int main(){
 long long N,i,sum=0;
 cin >> N;
 long long A[N+2];
 A[0]=0;
 A[N+1]=0;
 for (i=1;i<N+1;++i){
   cin >> A[i];
   sum += abs(A[i]-A[i-1]);
 }
 sum+=abs(A[N]);
 for (i=1;i<N+1;++i){
   cout << sum-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1]) << endl;
 }
 return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	int T;
   	T=1;
   	while(T--)
   	{
   		int S,W;
   		cin>>S>>W;
   		if(S<=W)
   			cout<<"unsafe"<<endl;
   		else
   			cout<<"safe"<<endl;

   	}
}

Measured memory_bytes: 3692