akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for (int i=0;i<(int)n;++i)

int dx[] ={0,1,0,-1};
int dy[] = {1,0,-1,0};
struct P {
  int d;
  int x,y;
  P(int d,int x,int y):d(d),x(x),y(y){}
};
bool operator<(const P &a, const P &b) {
  return a.d > b.d;
}
int main() {
  int r;
  while(cin >> r, r) {
    int w[2],h[2],sx[2],sy[2];
    int ba[2][500][500];
    rep(k,2) {
      cin >> w[k]>>h[k]>>sx[k]>>sy[k];
      sx[k]--;sy[k]--;
      rep(y,h[k])
        rep(x, w[k])
        cin >> ba[k][x][y];
    }
    int table[2][250001];
    rep(k,2) {
      priority_queue<P> Q;
      Q.push(P(1, sx[k], sy[k]));
      bool visited[w[k]][h[k]];
      memset(visited,0,sizeof(visited));
      int nowd = 0;
      int cnt = 0;
      while(!Q.empty()) {
        P p = Q.top();
        int x = p.x;
        int y = p.y;
        Q.pop();
        if (visited[x][y]) continue;
        nowd = max(nowd, p.d);
        table[k][++cnt] = nowd;
        //      printf("%d,%d -> %d\n",k,cnt,nowd);
        visited[x][y] = 1;
        rep(i,4) {
          int xx = x+dx[i];
          int yy = y+dy[i];

          if (xx<0||xx>=w[k]||yy<0||yy>=h[k]) continue;
          if (visited[xx][yy]) continue;
          Q.push(P(ba[k][xx][yy], xx, yy));
        }
      }
    }
    int res = 1<<29;
    for (int i=0; i<=r; ++i) {
      if (i>w[0]*h[0] || r-i>w[1]*h[1]) continue;
      //  printf("%d->%d %d->%d\n", i,table[0][i], r-i,table[1][r-i]);
      res = min(res, table[0][i]+table[1][r-i]);
    }
    cout << res << endl;
  
  }
}

Measured memory_bytes: 0
# coding: utf-8

people_num = int(input())

Transport_list = [0 for i in range(0,5)]
for i in range(5):
    Transport_list[i] = int(input())

bottle_nec = min(Transport_list)

if(people_num%bottle_nec == 0):
    print(people_num // bottle_nec + 4)
else:
    print(people_num // bottle_nec + 1 + 4)


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

int main() {
    int n;
    cin >> n;
    bool flag = false;
    string ans = "Three";
    char s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == 'Y') ans = "Four";
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

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

        int a,b,c,k,max,max_;
        a = Integer.parseInt(scan.next());   
        b = Integer.parseInt(scan.next());
        c = Integer.parseInt(scan.next());
        k = Integer.parseInt(scan.next());
        max = Math.max(a,b);
        max = Math.max(max,c);
        max_ = max;
        for(int i = 0;i < k;i++){
            max = max*2;
        }
        int ans;
        ans = max + a + b + c - max_;

        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
RATE = 380000.0

n = gets.chomp.to_i

s = 0.0

n.times do
  (x, u) = gets.chomp.split(' ')
  x = x.to_f
  case u
  when 'JPY' then
    s += x
  when 'BTC' then
    s += x * RATE
  end
end
    
puts s

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << N*800 - N/15*200;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  priority_queue<P> pq;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) pq.push({b[i], i});
  }
  ll ans = 0LL;
  while (!pq.empty()) {
    int p = pq.top().second;
    pq.pop();
    int l = (p + n - 1) % n;
    int r = (p + 1) % n;
    int s = b[l] + b[r];
    if (b[p] - a[p] < s) {
      cout << -1 << endl;
      return 0;
    }
    int c = (b[p] - a[p]) / s;
    b[p] -= c * s;
    ans += c;
    if (b[p] <= a[p]) continue;
    pq.push({b[p], p});
  }
  cout << ans << endl;
}


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N, K;
int ans = 1;

int main(){
	
	cin>>N>>K;
	
	REP( i, N-1 ){
		ans *= K-1;
	}
	
	ans *= K;
	
	cout<<ans<<endl;
	
	return 0;

}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

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

  int H, W;
  cin >> H >> W;
  vector<string> grid(H);
  for (int i = 0; i < H; ++i) {
    cin >> grid[i];
  }

  int ans = 0;
  vector<int> dx = {1, 0, -1, 0};
  vector<int> dy = {0, 1, 0, -1};
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (grid[i][j] == '#') continue;
      int tmp = 0;
      vector<vector<int>> dist(H, vector<int>(W, INF));
      priority_queue<P, vector<P>, greater<P>> que;
      dist[i][j] = 0;
      que.push(P(0, i * W + j));

      while (!que.empty()) {
        P p = que.top();
        que.pop();
        int d = p.first;
        int x = p.second / W;
        int y = p.second % W;
        if (dist[x][y] < d) continue;
        for (int k = 0; k < 4; ++k) {
          int tx = x + dx[k];
          int ty = y + dy[k];
          if (tx < 0 || tx >= H) continue;
          if (ty < 0 || ty >= W) continue;
          if (grid[tx][ty] == '#') continue;
          if (dist[tx][ty] > d + 1) {
            dist[tx][ty] = d + 1;
            que.push(P(d + 1, tx * W + ty));
          }
        }
      }
      for (int k = 0; k < H; ++k) {
        for (int l = 0; l < W; ++l) {
          if (dist[k][l] == INF) continue;
          tmp = max(tmp, dist[k][l]);
        }
      }
      // dump(i, j, tmp, dist);
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;
  
ll gcd(int a, int b) {
    if(b==0) return a;
    return gcd(b,a%b);
}
  
int main() {
ll a,b;
while(cin >> a >> b) cout << gcd(a,b) << " " << a * b / gcd(a,b) << endl;
return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>

int main(void) {

	unsigned long long int count=0;
	int n;
	int sumN=0;
	int i;
	int height[200100];
	int maxHeight=0;
	
	scanf("%d",&n);
	///printf("%d\n",n);
	for(i=0;i<n;i++){
		scanf("%d",&height[i]);
		//printf("%d",height[i]);
	}
	//printf("\n");
	
	maxHeight = height[0];
	
	for(i=1;i<n;i++){
		if(height[i] < maxHeight){
			count = count + maxHeight - height[i];
			//printf("%d ",count);
		}
		else{
			maxHeight = height[i];
			//printf("%d ",count);
		}
		/*
		if(height[i-1] > height[i]){
			count = count + height[i-1]-height[i];
			height[i] = height[i-1];
			//printf("%d",count);
		}
		*/

	}
	//printf("\n");
	
	
	printf("%llu\n",count);
	
	/*
	if(sumN%9 == 0){
		//printf("%d\n",sumN);
		printf("Yes\n");
	}
	else{
		//printf("%d\n",sumN);
		printf("No\n");
	}
	*/
	


}


Measured memory_bytes: 2484
//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(),(n).end()
#define clr(v,val) memset(v , val , sizeof v)
#define EPS 1e-9
#define OO 1e9
#define PI acos(-1.0)
#define ll long long
#define endl "\n"

void file(){
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}


ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int dx[] = { -1, 0, 1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//473,600
//7000
const int N = 2e6 + 5, mod = 1e9 + 7;

int main()
{
	/*** بسم الله الرحمن الرحيم  ***/
	//cout << fixed << setprecision(6);
	//file();
	fast();
	int x, y;
	cin >> x >> y;
	int a[300] = { 0 };
	a[1] = 300000;
	a[2] = 200000;
	a[3] = 100000;
	if (x == 1 && y == 1)
		cout << a[1] + a[1] + 400000;
	else cout << a[x] + a[y];
	
}

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

int main(){
    char A[10]={};
    int B[10]={};
    cin >> A;
    int bitsize=0;
    for(int i=0;i<11;i++){
        if(A[i]-48>0){
            B[i]=A[i]-48;
            if(i==10){
                bitsize=i;
            }
        }else{
            bitsize=i-1;
            break;
        }
    }

    int allbit=pow(2,bitsize);

    long long ans=0;
    long long compans=0;
    int count=0;

    for(int i=0;i<allbit;i++){
        compans=0;
        count=0;
        for(int j=0;j<bitsize+1;j++){
            if((i>>j)%2==0){
                compans=compans*10+B[count];
            }else{ 
                compans=compans*10+B[count];
                ans+=compans;
                compans=0;
            }
            count++;
        }
        ans+=compans;
        
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
module Main where

main :: IO ()
main = input >>= output


input :: IO [Char]
input = getLine

output :: [Char] -> IO ()
output s = output' (length s) 0 '0' '1' s
    where
        output' l i _ _ [] = print $ min i $ l - i
        output' l i c cl (x:xs)
            | c == x = output' l (i+1) cl c xs
            | otherwise = output' l i cl c xs


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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//const int MOD = 1e9 + 7;
const int MAX = 1e5 + 1;
int a[MAX];

int main()
{
	//IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int x;
		cin >> x;
		if(x < 600) cout << "8\n";
		else if(x < 800) cout << "7\n";
		else if(x < 1000) cout << "6\n";
		else  if(x < 1200) cout << "5\n";
		else if(x < 1400) cout << "4\n";
		else if(x < 1600) cout << "3\n";
		else if(x < 1800) cout << "2\n";
		else cout << "1\n";
	}
	return 0;
}



Measured memory_bytes: 3616
#include <iostream>
using namespace std;
#define MAX 20
int main()
{
	int n, p[MAX];
	int i;
	int ans = 0;
	cin >> n;
	for (i = 0; i < n; i++)cin >> p[i];
	for (i = 1; i < n - 1; i++) {
		if ((p[i - 1] < p[i] && p[i] < p[i + 1]) ||
			(p[i - 1] > p[i] && p[i] > p[i + 1]))ans++;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  long long N;
  cin>>N;
  long long A,B;
  A=1;
  B=N;
  for(long long i=2;i*i<=N;i++){
    if(N%i==0){
      A=i;
      B=N/i;
    }
  }
  int answer=0;
  while(max(A,B)>0){
    A/=10;
    B/=10;
    answer++;
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3140
n = int(input())
s = input()

flag = True
while flag:
    flag = False
    i = 0
    while i+1 < len(s):
        if s[i] == s[i+1]:
            flag = True
            s = s[:i] + s[i+1:]
            i += 1
        i += 1

print(len(s))


Measured memory_bytes: 3420
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C; cin>>A>>B>>C;
    int diff=3*max({A,B,C})-(A+B+C);
    if(diff%2==0) cout<<diff/2<<endl;
    else cout<<(diff+3)/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int n;
ll sum = 0;
cin >> n;
vector<ll>a(n - 1);
rep0(i, n - 1) {
	cin >> a[i];
}
sum += a[0];
rep0(j, n - 2) {
	sum += min(a[j], a[j + 1]);
}
sum += a[n-2];

cout << sum << endl;
return 0;
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = b - a + 1;
    ll divc = b / c - a / c + (a % c == 0);
    ll divd = b / d - a / d + (a % d == 0);

    ll dif = b / lcm(c, d) - a / lcm(c, d) + (a % lcm(c, d) == 0);
    cout << ans - divc - divd + dif << endl;

    return 0;
}

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

const int INF = 1e9+7;

// dp[0] = 0
// dp[i] = minimum(dp[i-j] + |h[i] - h[i-j]| where j in [1, K])

int main() {
    int N, K;
    int h[100010];
    int dp[100010];
    cin >> N >> K;

    for(int i = 0; i < N; ++i) {
        scanf("%d", h + i);
    }

    dp[0] = 0;
    for(int i = 1; i < N; ++i) {
        int tmp = INF;
        for(int j = 1; j <= min(K, i); ++j) {
            tmp = min(tmp, dp[i-j] + abs(h[i] - h[i-j]));
        }

        dp[i] = tmp;
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>a(m);
	vector<ll>b(m);
	vector<ll>count(n+1, 0);
	for (ll i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
	}
	for (ll i = 1; i <= n; i++) {

		for (ll j = 0; j < m; j++) {
			if (a[j] == i || b[j] == i) {
				count[i]++;
			}
		}
		cout << count[i] << endl;
	}

}



Measured memory_bytes: 256
X,N=map(int,input().split())
p=[0]*N
p=list(map(int,input().split()))
mixmix=float('inf')
hozon=-1
if(p.count(X)!=1):
    print(X)
    exit()
for i in range(1,101):
    if(p.count(X-i)!=1):
        print(X-i)
        exit()
    elif(p.count(X+i)!=1):
        print(X+i)
        exit()

Measured memory_bytes: 62028
import java.util.*

fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)


    val a = argList.nextLong()
    val b = argList.nextLong()
    val c = argList.nextLong()
    val d = argList.nextLong()
    val executor = AntiDivision()
    println(executor.execute(a, b, c, d))

}

class AntiDivision {
    fun execute(a: Long, b: Long, c: Long, d:Long ): Long {

        val allAmount = b - a + 1
        val divAmountByC = (b / c) - ((a - 1) / c)
        val divAmountByD = (b / d) - ((a - 1) / d)
        val gcd = calcGcd(c, d)
        val lcm = (c * d) / gcd
        val divAmountBoth = (b / lcm -  ((a - 1) / lcm))
        
        return allAmount - (divAmountByC + divAmountByD - divAmountBoth)
    }
    private tailrec fun calcGcd(a: Long, b: Long): Long =
            if ( b == 0L ) a
            else calcGcd(b, a % b)
}

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

int main() {
    int x, n;
    cin >> x >> n;

    vector<bool> hold(101, false);

    for (int i = 0; i < n; i++) {
        int t; cin >> t;
        hold[t] = true;
    }

    int ans = -100;
    for (int i = -100; i <= 0; i++) {
        if (abs(x - i) < abs(ans - x)) {
            ans = i;
        }
    }
    for (int i = 0; i <= 103; i++) {
        if (!hold[i]) {
            if (abs(x - i) < abs(ans - x)) {
                ans = i;
            }
        }
    }
    cout << ans << endl;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

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

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B,C = inputIL()

print((A*B//2))

Measured memory_bytes: 64364
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	long long a,b,x;
	cin >> a >> b >> x;
	long long c=b/x-a/x;
	if (a%x==0) c+=1;
	cout << c;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

while True:
    N = int(input())
    ans_list = sorted(make_divisors(N))
    ans = 0
    #print(ans_list)
    for i in ans_list:
        m = N // i - 1
        if N < m * m:
            #print(i)
            #print(N // i - 1)
            ans += (N // i - 1)

    print(ans)
    break

Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int n,k;
int min_cost[2010];
vector<int> g[2010];

void solve(int s, int t, int min_cost[2010]){
	REP(i,0,n) min_cost[i] = INF; min_cost[s] = 0; min_cost[t] = 0;
	queue<P> qu; qu.push({0, s}); qu.push({0, t});
	
	while(!qu.empty()){
		auto p = qu.front(); qu.pop();
		
		for(auto e:g[p.second]){
			if(p.first + 1 >= min_cost[e]) continue;
			min_cost[e] = p.first + 1;
			qu.push({min_cost[e], e});
		}
	}
}

int main(){
	cin >> n >> k;
	REP(i,0,n - 1){
		int a,b; cin >> a >> b;
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	
	int mi = INF;
	if(k%2){
		REP(i,0,n){
			for(auto e:g[i]){
				int c = 0;
				solve(i, e, min_cost);
				REP(i,0,n) if(min_cost[i] > (k - 1) / 2) c++;
				mi = min(mi, c);
			}
		}
	}else{
		REP(i,0,n){
			int c = 0;
			solve(i, i, min_cost);
			REP(i,0,n) if(min_cost[i] > k / 2) c++;
			mi = min(mi, c);
		}
	}
	
	cout << mi << endl;
	return 0;
}


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

int main()
{
   string s;
   int res=0;
   cin>>s;
   for(int i=0;i<s.size();i++){
    if(s[i]=='+')res++;
    else res--;
   }
   cout<<res<<endl;
   }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using tiii = tuple<int, int, int>;


int main()
{
    int n, q;
    cin >> n >> q;

    vector<int> graph[n];
    rep(i, 0, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> counter(n, 0);
    rep(i, 0, q)
    {
        int p, x;
        cin >> p >> x;
        --p;
        counter[p] += x;
    }

    queue<tiii> que;
    que.push(make_tuple(0, -1, 0));
    while (que.size() > 0)
    {
        int now, par, cnt;
        tie(now, par, cnt) = que.front();
        que.pop();

        counter[now] += cnt;
        // cout << "**" << now + 1<< ' ' << cnt << ' ' << counter[now] << endl;

        for (auto next: graph[now])
        {
            if (next == par) continue;
            que.push(make_tuple(next, now, counter[now]));
        }
    }

    rep(i, 0, n)
        printf("%d ", counter[i]);
    cout << endl;
    return 0;
}

Measured memory_bytes: 17140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

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

    ll N;
    cin >> N;

    ll cur = 1;

    for(ll i=0; i<N; i++)
    {
        ll a;
        cin >> a;

        if(a == cur)
        {
            cur++;
        }
    }

    cur--;

    if(cur == 0)
    {
        cout << -1 << endl;
    }

    else
    {
        cout << N-cur << endl;
    }

    return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll n; cin >> n;

    map<ll, ll> a;

    for (int i = 0; i < n; ++i) {
        ll t; cin >> t;
        a[t] += 1;
    }

    ll ans = 0;

    for (auto t : a) {
        if (t.first > t.second) {
            ans += t.second;
        }

        if (t.first < t.second) {
            ans += t.second - t.first;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6272
import           Control.Monad (replicateM)
import           Data.List     (sort)
import           Data.Ord      (Down (Down))

main :: IO ()
main = do
  n <- readLn
  sps <- replicateM n $ do
    [s, p] <- words <$> getLine
    pure (s, read p)
  mapM_ print $ solve sps

solve :: [(String, Int)] -> [Int]
solve = map (\(_, _, i) -> i) . sort . zipWith (\i (s, p) -> (s, Down p, i)) [1..]


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;

int n, m, q;
int a[50], b[50], c[50], d[50];

int dfs(vector<int> &v)
{
  if (v.size() == n)
  {
    int sum = 0;
    for (int i = 0; i < q; i++)
    {
      if (v[b[i]] - v[a[i]] == c[i])
        sum += d[i];
    }
    return sum;
  }

  int last = (v.empty() ? 1 : v.back());
  int Max = 0;
  for (int i = last; i <= m; i++)
  {
    v.push_back(i);
    Max = max(Max, dfs(v));
    v.pop_back();
  }
  return Max;
}

int main()
{
  cin >> n >> m >> q;
  for (int i = 0; i < q; i++)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }
  vector<int> v;
  cout << dfs(v) << endl;
  return 0;
}


Measured memory_bytes: 3604
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();

    let _n: usize = iter.next().unwrap().parse().unwrap();
    let s: String = iter.next().unwrap().parse().unwrap();

    let mut count: usize = 0;
    let mut abc_count: usize = 0;
    for x in s.chars() {
        match x {
            'A' => {
                abc_count = 1;
            },
            'B' => {
                if abc_count == 1 {
                    abc_count = 2;
                } else {
                    abc_count = 0;
                }
            },
            'C' => {
                if abc_count == 2 {
                    abc_count = 0;
                    count += 1;
                } else {
                    abc_count = 0;
                }
            },
            _ => {
                abc_count = 0;
            },
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    string exp;
    cin >> exp;
    const int exp_len = (int)exp.length();
    int co_ans;
    cin >> co_ans;

    stack<int> calc_m;
    for (int i = 0; i < exp_len; i++) {
        if (i % 2 == 0) {
            calc_m.push((int)(exp[i] - '0'));
        } else {
            if (exp[i] == '*') {
                int mul = calc_m.top() * ((int)(exp[i + 1] - '0'));
                calc_m.pop();
                calc_m.push(mul);
                i++;
            }
        }
    }

    int m = 0;
    while (!calc_m.empty()) {
        m += calc_m.top();
        calc_m.pop();
    }

    int l = exp[0] - '0';
    for (int i = 1; i < exp_len; i++) {
        if (i % 2 == 1) {
            if (exp[i] == '*') {
                l *= (exp[i + 1] - '0');
            } else {
                l += (exp[i + 1] - '0');
            }
        }
    }

    if (co_ans == m && co_ans == l) {
        cout << 'U' << endl;
    } else if (co_ans == m) {
        cout << 'M' << endl;
    } else if (co_ans == l) {
        cout << 'L' << endl;
    } else {
        cout << 'I' << endl;
    } 

    return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn=2E5+5;
ll ans;
int n,fa[maxn],a[maxn],sum[maxn],now[maxn],U[maxn];
int find(int x)
{
	return U[x]?U[x]=find(U[x]):x;
}
struct pt
{
	int w,now,id;
	pt(int a=0,int b=0,int c=0):w(a),now(b),id(c){}
	bool operator<(const pt&A)const
	{
		return (ll)now*A.w>(ll)w*A.now;
	}
};
priority_queue<pt>Q;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=2;i<=n;++i)
		cin>>fa[i];
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		sum[i]=1;
	}
	for(int i=1;i<=n;++i)
		if(!a[i])
		{
			int p=find(fa[i]);
			sum[p]+=sum[i];
			U[i]=p;
		}
	for(int i=1;i<=n;++i)
		if(a[i])
		{
			--sum[i];
			ans+=sum[i];
			Q.push(pt(sum[i],1,i));
			now[i]=1;
		}
	while(!Q.empty())
	{
		pt A=Q.top();
		Q.pop();
		int u=find(A.id);
		int F=find(fa[u]);
		if(!F||sum[u]!=A.w)
			continue;
//		cout<<"?? "<<u<<" "<<F<<endl;
		ans+=(ll)sum[u]*now[F];
		sum[F]+=sum[u];
		now[F]+=now[u];
		U[u]=F;
		Q.push(pt(sum[F],now[F],F));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 2e5+9, INF = 0x3f3f3f3f;
int dt[105], v[105];

int main( void ) {
    ios::sync_with_stdio( false );
    int n;
    cin >> n;
    --n;
    for( int i = 1; i <= n; ++i ) cin >> dt[i];
    v[0] = dt[1];
    dt[n + 1] = dt[n];
    for( int i = 1; i <= n; ++i ) {
        v[i] = min( dt[i], dt[i + 1] );
    }
    int ans = 0;
    for( int i = 0; i <= n; ++i ) ans += v[i];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 1e6+5, M = 1e6+6, OO = 0x3f3f3f3f;
int n, m;
int main()
{
    FIO
    cin>>n>>m;
    for(int i  = 0 ; i < m ; i++)
    {
        int x; cin>>x;
        n -= x;
    }
    cout<<max(-1, n)<<endl;
    return 0;
}

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


int main(void) {


    char str[3];
    scanf("%s", str);


       int a;
       int b;
       int c;

       if(str[0] == 'o'){
           a = 1;
       }else if(str[0] == 'x'){
           a = 0;
        }
    
        if(str[1] == 'o'){
            b = 1;
        }else if(str[1] == 'x'){
            b = 0;
        }
 
        if(str[2] == 'o'){
            c = 1;
        }else if(str[2] == 'x'){
             c = 0;
        }

    printf("%d\n",700+(a+b+c)*100);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
const int MOD = 1000000007;
#define rep(i,n) for (int i=0; i < (n); i++)
using namespace std;
int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main () {
  int n, q;
  scanf("%d %d", &n, &q);

  vector<vector<int>> v(n);
  rep(i,n-1) {
    int a,b;
    scanf("%d %d", &a, &b);
    a--; b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  vector<int> counter(n, 0);
  rep(i,q) {
    int p,x;
    scanf("%d %d", &p, &x);
    p--;
    counter[p] += x;
  }

  function<void(int,int,int)> accumulate_dfs = [&](int self, int parent, int parent_count){
    counter[self] += parent_count;
    for (int& child: v[self]) {
      if (child != parent) {
        accumulate_dfs(child, self, counter[self]);
      }
    }
    return;
  };

  accumulate_dfs(0,-1,0);

  rep(i,n) {
    printf("%d ", counter[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 29696
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX_N = 100000;

int n, a[MAX_N];
int q, k;

int main(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> k;
		cout << lower_bound(a, a + n, k) - a << endl;
	}
	return 0;
}



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

int main() {
  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  if (v-w > 0 && abs(a - b) <= t*(v-w)) cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3632
## abc070d: Transit Tree Path

n = int(input())

T = [{} for _ in range(n)]
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    T[v1-1][v2-1] = d
    T[v2-1][v1-1] = d

q,k = map(int, input().split())

visit = [False]*n
depth = [0]*n
stack = [[-1,k-1,0]]
while stack:
    p,c,d = stack.pop()
    if visit[c]: continue
    visit[c] = True
    depth[c] = d
    if p>=0: depth[c] += depth[p]
    for cc in T[c].keys():
        if not visit[cc]: stack.append([c,cc,T[c][cc]])

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1-1]+depth[v2-1])

Measured memory_bytes: 59008
package main

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

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func mmin(a []int) int {
	r := int(1e10)
	for i := range a {
		r = min(r, a[i])
	}
	return r
}
func mmax(a []int) int {
	r := -int(1e10)
	for i := range a {
		r = max(r, a[i])
	}
	return r
}
func kcnt(a []int, k int) int {
	r := 0
	for i := range a {
		if a[i] == k {
			r++
		}
	}
	return r
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt(sc)
	}
	q := nextInt(sc)
	ans := make([]int, q)
	for i := 0; i < q; i++ {
		b := nextInt(sc)
		e := nextInt(sc)
		k := nextInt(sc)
		ans[i] = kcnt(a[b:e], k)
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := range ans {
		fmt.Fprintf(wtr, "%d\n", ans[i])
	}
	wtr.Flush()
}



Measured memory_bytes: 1136
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, D, X;
  std::cin >> N >> D >> X;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  const ll MAX_D = 100;
  std::map<ll, ll> mc;
  for (ll i = 0; i < N; i++) {
    for (ll d = 0; d <= MAX_D; d++) {
      ll day = va[i] * d + 1;
      mc[day]++;
    }
  }

  ll sum = X;
  for (ll j = 1; j <= D; j++) {
    sum += mc[j];
  }

  print(sum);
  return 0;
}


Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	a, b := readInt(), readInt()
	n := b - a
	fmt.Println(n*(n+1)/2 - b)
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

//?´?????????????????§????
//Union-Find??¨
struct UnionFind {
	vector<int> par;
	vector<int> rank;
	UnionFind(int n) :par(n), rank(n, 0) {
		for (int i = 0; i < n; i++)
			par[i] = i;
	}
	void unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
	int size(int x) { return -par[root(x)]; }
	void dump() {
		for (int i = 0; i < par.size(); i++) cout << par[i] << " ";
		cout << "par" << endl;
		for (int i = 0; i < rank.size(); i++) cout << rank[i] << " ";
		cout << "rank" << endl;
	}
};

int main() {
	int n, q; cin >> n >> q;
	UnionFind UF(n);

	//UF.dump();
	for (int i = 0; i < q; i++) {
		int com, x, y; cin >> com >> x >> y;
		if (com == 0)UF.unite(x, y);
		else cout << UF.same(x, y) << endl;
		//UF.dump();
	}
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second


typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll MOD = 1e9+7;
const int INF = numeric_limits<int>::max();

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

	int n, k; cin >> n >> k;
	vi v(n), dp(n, INF);
	for(auto& p: v) cin >> p;

	dp[0] = 0;
	for(int i = 1; i < n; i++)
		for(int j = i-1; j>=max(i-k, 0); j--)
			dp[i] = min(dp[i], dp[j] + abs(v[i]-v[j]));

	cout << dp[n-1] << '\n';

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long ll;
const ll LLINF=1ll<<60;
const int mx=1e6+7;
int n,m;
//vector<int> a(mx),b(mx);
// vector<int> g[mx];
// int deg[mx];
 vector<int> adj[mx];
//vector<int> ans;
//---dfs--
//bool visited[mx];
//vector<ll> val(mx,0);

int dfs(int s, vector<bool>& visited){
	//int sz=(int)adj[s].size();
	int ans=1;
	visited[s]=true;
	for(int i=0;i<(int)adj[s].size();i++){
		if(visited[adj[s][i]]==false){
			//sz+=dfs(adj[s][i], visited);
			ans+=dfs(adj[s][i], visited);
		}
	}
	return ans;
}

int mxedge(){
	int res=-INT_MAX;
	vector<bool> visited(n,false);
	for(int i=0;i<n;i++){
		if(visited[i]==false){
			int ans=0;
			//int sz=dfs(i,visited);
			ans+=dfs(i,visited);
			res=max(res,ans);
		}
	}
	return res;
}
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		cin>>n>>m;
		set<pair<int,int>> st;
		for(int i=0;i<m;i++){
			int x,y;
			cin>>x>>y;
			x--,y--;
			if(st.find({x,y})==st.end()){
				adj[x].push_back(y);
				adj[y].push_back(x);
				st.insert({x,y});
				st.insert({y,x});
			}
		}
		// for(auto x:st){
		// 	cout<<x.first<<" "<<x.second<<"\n";
		// }
		int ans=mxedge();
		cout<<ans<<"\n";
 	}
}


Measured memory_bytes: 61448
//
// Created by Hideaki Imamura on 2019-12-09.
//
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

ll n, x, d;

ll calc_l(ll k_0, ll k) {
    return k * (k - 1) / 2 + (k - k_0) * x / d;
}

ll calc_r(ll k_0, ll k) {
    return k * (2 * n - k - 1) / 2 + (k - k_0) * x / d;
}

int main() {
    cin >> n >> x >> d;

    if (d == 0) {
        if (x == 0) {
            cout << 1 << endl;
        } else {
            cout << n + 1 << endl;
        }
        return 0;
    } else if (d < 0) {
        d = -d;
        x = -x;
    }

    unordered_map < ll, vector < pair < pair < ll, ll >, ll > >> lrk_map;
    ll kx_mod_d, l, r;
    for (int k = 0; k <= n; ++k) {
        kx_mod_d = ((k * x) % d + d) % d;
        if (lrk_map.find(kx_mod_d) != lrk_map.end()) {
            l = calc_l(lrk_map[kx_mod_d][0].second, k);
            r = calc_r(lrk_map[kx_mod_d][0].second, k);
            lrk_map[kx_mod_d].push_back({{l, r}, k});
        } else {
            l = calc_l(k, k);
            r = calc_r(k, k);
            lrk_map[kx_mod_d] = {{{l, r}, k}};
        }
    }

    ll ans = 0, cur_l, cur_r;
    vector < pair < pair < ll, ll >, ll >> lrk_vec;
    for (auto lrk_vec_pair : lrk_map) {
        lrk_vec = lrk_vec_pair.second;
        sort(lrk_vec.begin(), lrk_vec.end());
        cur_l = lrk_vec[0].first.first;
        cur_r = lrk_vec[0].first.second;
        for (auto lrk : lrk_vec) {
            l = lrk.first.first;
            r = lrk.first.second;
            if (l <= cur_r && cur_r <= r) {
                cur_r = r;
            } else if (cur_r < l) {
                ans += cur_r - cur_l + 1;
                cur_l = l;
                cur_r = r;
            }
        }
        ans += cur_r - cur_l + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 17864
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int r, d, x;
    cin >> r >> d >> x;
    int tmp = x;

    for (int i = 0; i < 10; i++) {
        int tmp1 = r*tmp - d;
        cout << tmp1 << endl;
        tmp = tmp1;
    }
    return 0;
}


Measured memory_bytes: 256
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int n, b[105];
int main() {
	cin >> n;
	for (int i = 1; i < n; ++i) cin >> b[i];
	LL ans = b[1];
	for (int i = 1; i < n - 1; ++i) ans += min(b[i], b[i + 1]);
	cout << ans + b[n - 1];
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  ll ans = 0;
  for(int i = 1; i < N; i++) {
    if(A[i] < A[i - 1]) {
      ans += A[i - 1] - A[i];
      A[i] = A[i- 1];
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

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

const ll INFL = 810000001919114514;
const int INF =         1919114514;

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

	int a,b;
	cin>>a>>b;
	a+=11;
	a%=13;
	b+=11;
	b%=13;

	if(a<b)
		cout<<"Bob"<<en;
	else if(a>b)
		cout<<"Alice"<<en;
	else
		cout<<"Draw"<<en;

	return 0;
}

Measured memory_bytes: 256