akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int manLength(int x1,int y1,int x2,int y2){
	return abs(x1-x2) + abs(y1-y2);
}
int main()
{
	string a,b;
	cin>>a;
	cin>>b;
	if(a.length() > b.length()){
		cout<<"GREATER"<<endl;
	}else if(b.length() > a.length()){
		cout<<"LESS"<<endl;
	}else{
		bool equal = true;
		for(int i = 0; i < a.length(); i++){
			int localA,localB;
			localA = a[i] - '0';
			localB = b[i] - '0';
			if( localA > localB){
				cout<<"GREATER"<<endl;
				equal = false;
				break;
			}else if(localA < localB){
				cout<<"LESS"<<endl;
				equal = false;
				break;
			}
		}
		if( equal == true){
			cout<<"EQUAL"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
void printAns(bool can);

/* main */
int main(){
    int q, option, num; 
    set<int> S;
    cin >> q;
    for (int i  = 0; i < q; i++) {
        cin >> option >> num;
        switch(option) {
        case 0:
            // insert
            S.insert(num);
            cout << S.size() << '\n';
            break;
        case 1:
            // find
            cout << S.count(num) << '\n';
            break;
        case 2:
            // delete
            S.erase(num);
            break;
        }
    }
}


void printAns(bool can) {
    if (can) cout << 1 << '\n';
    else cout << 0 << '\n';
}



Measured memory_bytes: 12472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const ll INF = 1001001001000000;

ll dp[110][100100];
int main(){
  int n, W;
  cin >> n >> W;
  ll w[110], v[110];
  rep(i, n) cin >> w[i] >> v[i];

  rep(i, 110) rep(j, 100100) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i, n) {
    for(int j = 0; j <= 100000; ++j) {
      dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
      if(j - v[i] >= 0) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
    }
  }
  
  ll ans = 0;
  rep(i, 100001) {
    if(dp[n][i] <= W) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    cin >> N;
    for(int i=1;i<=N;i++){
        if((int)(1.08*i)==N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;

namespace std {
    template <>
    class hash<std::pair<int, int>> {
    public:
        size_t operator()(const std::pair<int, int>& x) const{
            return hash<int>()(x.first) ^ hash<int>()(x.second);
        }
    };
}

int ceil(int a,int b){
	return (a+b-1)/b;
}

ll gcd(ll a,ll b){
	ll p;

	if (b > a){
		p = a;
		a = b;
		b = p;
	}

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

int main(){
	ll N;
	cin >> N;

	ll A[N];
	REP(i,N) cin >> A[i];

	ll ret;

	if(N==2){
		ret = max(A[0],A[1]);
	}else{
		ll L[N];
		ll R[N];

		L[0] = A[0];
		REPI(i,1,N){
			L[i] = gcd(L[i-1],A[i]);
		}

		R[N-1] = A[N-1];
		for(ll i = N-2; i>=0;i--){
			R[i] = gcd(R[i+1],A[i]);
		}

		ret = R[1];
		REPI(i,1,N-1){
			ret = max(ret,gcd(L[i-1],R[i+1]));
		}
		ret = max(ret,L[N-2]);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int N;
vector<lint> x, y;

int main()
{
    cin >> N;
    x.resize(N);
    y.resize(N);
    lint min_=1000000000, max_=1;
    for (int i=0; i<N; i++)
    {
        cin >> x[i] >> y[i];
        if (x[i] > max_) max_ = x[i];
        if (y[i] > max_) max_ = y[i];
        if (x[i] < min_) min_ = x[i];
        if (y[i] < min_) min_ = y[i];
    }
    if (min_ == max_ )
    {
        cout << "0" << endl;
        return 0;
    }
    int tmp = 0;

    lint ans = (max_ - min_) * (max_ - min_);

    // 最大と最小が違う色になる場合
    {
        lint Rmax = max_;
        lint Rmin = max_;
        lint Bmax = min_;
        lint Bmin = min_;
        for (int i=0; i<N; i++)
        {
            Rmin = min(Rmin, max(x[i], y[i]));
            Bmax = max(Bmax, min(x[i], y[i]));
        }
        ans = min(ans, (Rmax-Rmin)*(Bmax-Bmin));
    }

    for (int i=0; i<N; i++)
    {
        if (x[i] == min_ || x[i] == max_ || y[i] == min_ || y[i] == max_) tmp++;
    }
    if (tmp > 1)
    {
        // 最小と最大が同じ色の場合
        priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int>> >pq;
        lint max_tmp = 1;
        lint min___ = 1000000000;
        for (int i=0; i<N; i++)
        {
            pq.push(make_pair(min(x[i], y[i]), i));
            max_tmp = max(max_tmp, min(x[i], y[i]));
            min___ = min(min___, max(x[i], y[i]));
        }
        ans = min(ans, (max_-min_) * (max_ - min___));
        lint min_tmp = max_tmp;
        for (int i=0; i<N; i++)
        {
            // cout << i << " " << pq.top().first << " " << pq.top().second << " " << max_tmp << " " << endl;
            ans = min(ans, (max_tmp - min((lint)pq.top().first, min_tmp)) * (max_ - min_));
            int where = pq.top().second;
            max_tmp = max(max_tmp, max(x[where], y[where]));
            min_tmp = min(min_tmp, max(x[where], y[where]));
            pq.pop();
        }
    }
    cout << ans << endl;    
}

Measured memory_bytes: 5492
n = int(input())
l = [[int(x) for x in input().split()] for _ in range(n-1)]
for i in range(n-1):
    ans = 0
    ans += l[i][1] + l[i][0]
    for j in range(i+1, n-1):
        if ans < l[j][1]: ans = l[j][1]
        if ans % l[j][2] != 0:
            ans += l[j][2] - ans % l[j][2]
        ans += l[j][0]
    print(ans)
print(0)

Measured memory_bytes: 3188
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
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
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	H, W := scanInt(), scanInt()
	c0, c1 := scanInt()-1, scanInt()-1
	d0, d1 := scanInt()-1, scanInt()-1

	s := make([]string, H)
	for i := 0; i < H; i++ {
		s[i] = scanString()
	}

	g := make([][]int, H)
	inf := 1 << 60
	for i := 0; i < H; i++ {
		g[i] = make([]int, W)
		for j := 0; j < W; j++ {
			g[i][j] = inf
		}
	}
	dx, dy := []int{0, 1, 0, -1}, []int{1, 0, -1, 0}

	pq := &pqAsc{pair{c0, c1, 0}}
	heap.Init(pq)
	g[c0][c1] = 0

	for len(*pq) != 0 {
		nt := heap.Pop(pq).(pair)
		if nt.c != g[nt.a][nt.b] {
			continue
		}
		for i := 0; i < 4; i++ {
			nx, ny := nt.a+dx[i], nt.b+dy[i]
			if nx < 0 || nx >= H || ny < 0 || ny >= W || s[nx][ny] == '#' {
				continue
			}
			if g[nx][ny] > nt.c {
				heap.Push(pq, pair{nx, ny, nt.c})
				g[nx][ny] = nt.c
			}
		}

		for i := -2; i <= 2; i++ {
			for j := -2; j <= 2; j++ {
				nx, ny := nt.a+i, nt.b+j
				if nx < 0 || nx >= H || ny < 0 || ny >= W || s[nx][ny] == '#' {
					continue
				}
				if g[nx][ny] > nt.c+1 {
					heap.Push(pq, pair{nx, ny, nt.c + 1})
					g[nx][ny] = nt.c + 1
				}
			}
		}
	}
	if g[d0][d1] == inf {
		fmt.Fprintln(wr, -1)
	} else {
		fmt.Fprintln(wr, g[d0][d1])
	}
}

type pair struct{ a, b, c int }

type pqAsc []pair

func (pq pqAsc) Len() int            { return len(pq) }
func (pq pqAsc) Swap(i, j int)       { pq[i], pq[j] = pq[j], pq[i] }
func (pq pqAsc) Less(i, j int) bool  { return pq[i].c < pq[j].c }
func (pq *pqAsc) Push(x interface{}) { *pq = append(*pq, x.(pair)) }
func (pq *pqAsc) Pop() interface{} {
	x := (*pq)[len(*pq)-1]
	*pq = (*pq)[0 : len(*pq)-1]
	return x
}


Measured memory_bytes: 25392
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(5<a&&5<b){
			if(b<a){
				cout<<a;
				for(int i=a+1;i<10;i++)cout<<' '<<i;
				for(int i=5;i>0;i--)cout<<' '<<i;
				for(int i=0;i<=b;i++)cout<<' '<<i;
			}else{
				cout<<a;
				for(int i=a+1;i<=b;i++)cout<<' '<<i;
			}
		}else if(5<a){
			cout<<a;
			for(int i=a+1;i<10;i++)cout<<' '<<i;
			for(int i=5;i>=b;i--)cout<<' '<<i;
		}else if(5<b){
			cout<<a;
			for(int i=a+1;i<=b;i++)cout<<' '<<i;
		}else{
			if(b<a){
				cout<<a;
				for(int i=a-1;i>=b;i--)cout<<' '<<i;
			}else{
				cout<<a;
				for(int i=a+1;i<=b;i++)cout<<' '<<i;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int main(){
	int n, m, temp;
	cin >> n >> m;
	priority_queue<int> a;
	for (int i = 0; i < n; i++){
		cin >> temp;
		a.push(temp);
	}
	for (int i = 0; i < m; i++){
		temp = a.top();
		a.pop();
		a.push(temp/2);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++){
		ans += a.top();
		a.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  std::vector<int> ary(17);
  unsigned long N;
  int len = 0;
  std::cin >> N;
  for (int i = 0; i < 17; i++) {
    ary[i] = (int) (N % 10);
    N /= 10;
    len++;
    if (N == 0) break;
  }

  int max = 0;
  for (int i = 0; i < len; i++) {
    int sum = 0;
    for (int j = 0; j < len; j++) {
      sum += ary[j];
    }
    max = std::max(max, sum);
    if (ary[i] != 9) {
      ary[i] = 9;
      for (int j = i + 1; j < len; j++) {
        if (ary[j] != 0) {
          ary[j]--;
          break;
        } else ary[j] = 9;
      }
    }
  }

  std::cout << max;

  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using edge = struct {
  int next;
  long d;
};
vector<edge> tree[100000];
long depth[100000] = {};

void dfs(int n, int p, long d) {
  depth[n] = d;
  for (auto &e : tree[n]) {
    if (e.next == p)
      continue;
    dfs(e.next, n, d+e.d);
  }
}

int main() {
  int n;
  cin >> n;
  int a, b;
  long c;
  for (int i=0; i<n-1; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    tree[a].push_back({b, c});
    tree[b].push_back({a, c});
  }
  int q, k, x, y;
  cin >> q >> k;
  k--;
  dfs(k, -1, 0);
  for (int i=0; i<q; i++) {
    cin >> x >> y;
    cout << depth[x-1]+depth[y-1] << '\n';
  }
  return 0;
}

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

int main(void)
{
    int q;
    double x;

    while (1){
        scanf("%d", &q);
        if (q == -1){
            break;
        }

        x = q / 2.0;
        while (fabs(x * x * x - q) >= 1e-5 * q){
            x = x - (x * x * x - q) / (3 * x * x);
        }
        printf("%f\n", x);
    }

    return (0);
}

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

int main(){

  int i=0,j,k ,l;
  int exam[1000][4];
  
  for(i=0;i<1000;i++)
    {
      cin >>exam[i][0] >>exam[i][1] >>exam[i][2];
      
      if(exam[i][0] == -1 && exam[i][1] == -1 && exam[i][2] == -1)
	break;
      
    }
  
  
  
  for(k=0;k < i+1;k++)
    {
      
      exam[k][3] = exam[k][0] + exam[k][1];
      
      if(exam[k][0] == -1 || exam[k][1] == -1 ||exam[k][3] < 30){
	exam[k][3] = -1;
      }else{
	
	if(exam[k][3]< exam[k][2] && exam[k][2] != -1 && exam[k][2] >= 50)
	  exam[k][3] = 50;
	
	
      }
    }
  
  for(j=0;j < i;j++){
    
    if(exam[j][3] >= 80)
      cout <<"A\n";
    else if(exam[j][3]<80 && exam[j][3]>=65)
      cout <<"B\n";
    else if(exam[j][3] <65 && exam[j][3]>=50)
      cout<<"C\n";
    else if(exam[j][3]<50 &&exam[j][3]>=30)
      cout<<"D\n";
    else 
      cout<<"F\n";
    
  }
  
  return 0;
}

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

using namespace std;

int main() {
    char S[100];
    cin >> S;
    if (S[0] == 'S') cout << "Cloudy";
    if (S[0] == 'C') cout << "Rainy";
    if (S[0] == 'R') cout << "Sunny";
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class C100To105 {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        ll x;cin >> x;
        ll m = 100000;
        for(int i = 1;i <= m/100;i++){
            if(x - 100*i >= 0 and x - 100*i <= 5*i){
                cout << 1 << endl;
                return;
            }
        }
        cout << 0 << endl;
        return;
    }
};

int main() {
	C100To105 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
  int N ; cin >> N ; 
  string S ; cin >> S ; 

  int ans = 0 ; 
  
  for(int i = 1 ; i < N ; i++){
    int cnt = 0 ; 
    
    for(char c = 'a' ; c <= 'z'  ; c++){
      bool left = false , right = false ; 
      
      for(int j = 0 ; j < i ; j++){
        if(S.at(j) == c) left = true ; 
      }
      for(int j = i ; j < N ; j++){
        if(S.at(j) == c) right = true ; 
      }
      
      if(left && right ) cnt++ ; 
    }
    ans = max(ans , cnt ) ; 
  }
  
  cout << ans << endl ; 
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S, T;
    cin >> N >> S >> T;
    for(int i = 0; i < N; i++) {
        cout << S[i] << T[i];
    }
    return 0;
}


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

const int INF = numeric_limits<int>::max();

int main()
{
    int v, e;
    cin >> v >> e;
    vector<vector<int>> dp(v, vector<int>(v, INF));
    for (int i = 0; i < v; i++) dp[i][i] = 0;

    for (int i = 0; i < e; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        dp[s][t] = d;
    }


    for (int k = 0; k < v; k++) {
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < v; j++) {
                if (dp[i][k] != INF && dp[k][j] != INF) {
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }
    }

    for (int i = 0; i < v; i++) {
        if (dp[i][i] < 0) {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    for (int i = 0; i < v; i++) {
        for (int j = 0; j < v; j++) {
            if (j > 0) {
                cout << " ";
            }
            if (dp[i][j] == INF) {
                cout << "INF";
            } else {
                cout << dp[i][j];
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3184
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

W, H, N =  nl()

left = 0
right = W
top = H
bottom = 0

for i in range(N):
    x, y, a = nl()
    if a == 1:
        left = max(left, x)
    elif a == 2:
        right = min(right, x)
    elif a == 3:
        bottom = max(bottom, y)
    else:
        top = min(top, y)

print(max(top - bottom, 0) * max(right - left, 0))



Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void){
 
 
 
    int a,b,c;
  
 
   cin >> a>>b>>c;
    
  if(a<b&&b<c){
      
            cout<<"Yes"<<endl;
     
    
    }
    else{
        cout<<"No"<<endl;
    }
    
    
    return 0;
 
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int A[] = new int[N];
    int B[] = new int[N];
    int C[] = new int[N - 1];
    int sum = 0;

    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }

    for (int i = 0; i < N - 1; i++) {
      C[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      int num = A[i];
      sum += B[num - 1];

      if (i != 0 && A[i] - A[i - 1] == 1) {
        sum += C[A[i - 1] - 1];
      }
    }

    System.out.println(sum);

    sc.close();
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i,t,n) for(int i=t;i<n;i++)
#define nd "\n"
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>




/*ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}*/
/*ll ph[100001];
void E_phi(int n){

ph[0]=0;
ph[1]=1;
for(int i=2;i<=n;i++){
    ph[i]=i;
}
for(int i=2;i<=n;i++){
    if(ph[i]==i){
        for(int j=i;j<=n;j+=){
            ph[j]-=ph[j]/i;
        }
    }
}


}*/
/*string s,t;
vector<int>  z_fun(string s){

int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}*/

/*struct st{
ll sum,pre,suf,ans;
st(){}
st(ll k){
ans=k,pre=k,suf=k,sum=0;
}

};
ll t[4*200001+4];
ll a[200001];
ll lazy[4*200001+4];
ll mx=1e14;



void push(int ind){
int l=2*ind+1,r=2*ind+2;
t[l]+=lazy[ind];
t[r]+=lazy[ind];
lazy[l]+=lazy[ind];
lazy[r]+=lazy[ind];
lazy[ind]=0;

}

void build(int ind,int l,int r){
if(l==r){
    t[ind]=a[l];
return;
}
int mid=(l+r)/2;
build(2*ind+1,l,mid);
build(2*ind+2,mid+1,r);

  t[ind] =min(t[ind*2+1] , t[ind*2+2]);



}
ll query(int ind,int l,int r,int p,int q){

if(l>q || r<p )
    return mx;
    int mid=(l+r)/2;

if(l>=p && r<=q )
    {
      return t[ind];
    }
    push(ind);
ll x=query(2*ind+1,l,mid,p,q);
ll y=query(2*ind+2,mid+1,r,p,q);


return min(x,y);
}

void update(int ind,int l,int r,int p,int q,int val){
if(l>q || r<p )
    return;

if(l>=p && r<=q )
    {
      t[ind]+=val;
      lazy[ind]+=val;
      return;
    }
push(ind);
int mid=(l+r)/2;
    update(2*ind+1,l,mid,p,q,val);
     update(2*ind+2,mid+1,r,p,q,val);
    t[ind]=min(t[2*ind+1],t[2*ind+2]);



}


ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}
*/

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x;
    cin>>x;
    cout<<(x+1)%2<<endl;

}


Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[][] d = new int[n][2];
        int x,l;
        for(int i=0;i<n;i++){
            x = Integer.parseInt(sc.next());
            l = Integer.parseInt(sc.next());
            d[i][0] = x-l;
            d[i][1] = x+l;
        }
        sc.close();
        Arrays.sort(d,new Comparator<int[]>(){

            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1]-o2[1];
            }

        });
        int end = Integer.MIN_VALUE;
        int res = 0;
        for(int i=0;i<n;i++){
            if(d[i][0] >= end){
                res++;
                end = d[i][1];
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 64660
#include<iostream>
using namespace std;
int a(int a,int b){return a+b;}
int b(int a,int b){return a-b;}
int c(int a,int b){return a*b;}
int d(int a,int b){return a/b;}
int main(){
  int n,m;
  char op;
  while(cin >> n >> op >> m&& op!='?'){
    if(op=='+')cout << a(n,m) << endl;
    else if(op=='-')cout << b(n,m) << endl;
    else if(op=='*')cout << c(n,m) << endl;
    else if(op=='/')cout << d(n,m) << endl;
  }
}


Measured memory_bytes: 3104
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<ll> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
ll inv(ll a, ll b){ return a<2 ? a : ((a-inv(b%a,a))*b+1)/a%b; }
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}



int p[200100],cnt[3000];
const int mod=2019;
string s;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	
	int N=s.length(),i,pp=1;
	reverse(all(s));
	for (i=1; i<=N; i++){
		p[i]=((s[i-1]-'0')*pp+p[i-1])%mod;
		
		pp=pp*10%mod;
	}
	
	
		
	cnt[0]=1;
	ll res=0;
	for (i=1; i<=N; i++){
		res+=cnt[p[i]];
		
		cnt[p[i]]++;
	}
	
	cout << res << "\n";
	
	
	
	
	return 0;
}



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

#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define rep(x, l, r) for (x = l; x < r; x++)

const ll mod=1000000007;

void solve()
{
	ll i, j, k, l, m, n, x, y, u, v, r, p,a,b,aa,bb;
	cin>>n;
	string ans="";
    while(n>0){
        k=n%26;
        if(k==0){
            k=26;
            n--;
        }
        ans+= (char)((int)'a'+(k-1));
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;



}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
//    cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3652
use std::cell::RefCell;

use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        es: [(u32, usize, usize); q],
    }

    let mut uf = UnionFind::new(n);
    for (t, u, v) in es {
        match t {
            0 => {
                uf.unite(u, v);
            }
            1 => println!("{}", if uf.equivalent(u, v) { 1 } else { 0 }),
            _ => {}
        }
    }
}

pub trait DisjointSet {
    fn new(len: usize) -> Self;
    fn representative(&self, id: usize) -> usize;
    fn equivalent(&self, lhs: usize, rhs: usize) -> bool {
        self.representative(lhs) == self.representative(rhs)
    }
    fn unite(&mut self, lhs: usize, rhs: usize) -> bool;
    fn count(&self, id: usize) -> usize;
}

struct UnionFind {
    par: RefCell<Vec<usize>>,
    size: RefCell<Vec<usize>>,
}

impl DisjointSet for UnionFind {
    fn new(len: usize) -> Self {
        Self {
            par: RefCell::new((0..len).collect()),
            size: RefCell::new(vec![1; len]),
        }
    }
    fn representative(&self, v: usize) -> usize {
        if self.par.borrow()[v] != v {
            let p = self.par.borrow()[v];
            self.par.borrow_mut()[v] = self.representative(p);
        }
        self.par.borrow()[v]
    }
    fn unite(&mut self, u: usize, v: usize) -> bool {
        let (u, v) = {
            let u = self.representative(u);
            let v = self.representative(v);
            if u == v {
                return false;
            }
            if self.size.borrow()[u] <= self.size.borrow()[v] {
                (u, v)
            } else {
                (v, u)
            }
        };
        let cs = self.size.borrow()[u];
        self.size.borrow_mut()[v] += cs;
        self.par.borrow_mut()[u] = v;
        true
    }
    fn count(&self, v: usize) -> usize {
        let v = self.representative(v);
        self.size.borrow()[v]
    }
}


Measured memory_bytes: 10836
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double ans=0;
    for(int i=0;i<n;i++){
        double x;
        string s;
        cin>>x>>s;
        if(s=="BTC") x*=380000;
        ans+=x;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    vector<int> a(3);
    for(int i=0; i<3; i++) cin >> a[i];
    sort(a.begin(), a.end());

    cout << a[2]-a[0] << endl;
}

Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll K;

int main() {
  cin >> K;
  
  int N = 50;
  cout << N << endl;
  for (int i = 0; i < N; ++i) {
    ll a = i;
    a += K/N;
    a -= K%N;
    if (i < K%N) a += N+1;
    printf("%lld%c", a, i+1 == N ? '\n' : ' ');
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,l,r) for(ll i=l;i<(ll)(r);i++) //ll
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;
const int INF = (1<<30);
int upcmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a>*(int*)b?1:-1));}
void sort_ui(int*a, int n){qsort(a,n,sizeof(int),upcmpii);}

int H,W;
int sx,sy,gx,gy;
char s[1010][1010];
int cnt[1010][1010] = {0};
ll ans = 0;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
int qxf = 0, qxb = 0, quex[101010101];
int qyf = 0, qyb = 0, quey[101010101];

void dfs(int cx,int cy){
    cnt[cx][cy] = ans+1;
    rep(i,4){
        int nx = cx+dx[i];
        int ny = cy+dy[i];
        if(nx >= 0&&nx < H&&ny >= 0&&ny < W){
            if(cnt[nx][ny] == 0 && s[nx][ny] == '.'){
                dfs(nx,ny);
            }
        }
    }
    rep(i,5) rep(j,5) {
        if(cx-2+i >= 0&&cx-2+i < H&&cy-2+j >= 0&&cy-2+j < W){
            if(cnt[cx-2+i][cy-2+j] == 0 && s[cx-2+i][cy-2+j] == '.'){
                quex[qxb++] = cx-2+i;
                quey[qyb++] = cy-2+j;
            }
        }
    }
}

void solve(){
    dfs(sx,sy);
    while(cnt[gx][gy] == 0){
        ans++;
        int m = qxb-qxf;
        int tmp = 0;
        rep(i,m){
            int nnx = quex[qxf++],nny = quey[qyf++];
            if(cnt[nnx][nny] == 0) {dfs(nnx,nny);tmp++;}
        }
        if(tmp == 0 && cnt[gx][gy] == 0){
            ans = -1;
            break;
        }
    }
}

int main(){
    scanf("%d%d%d%d%d%d", &H,&W,&sx,&sy,&gx,&gy);
    sx--;sy--;gx--;gy--;
    rep(i, H) scanf("%s", s[i]);

    solve();

    printf("%lld", ans);
}

Measured memory_bytes: 15684
fun main(args: Array<String>) {
    val input = readLine()!!.reversed()
    val words = listOf("dream", "dreamer", "erase", "eraser").map(String::reversed)
    val wl = words.map{it to it.length}
    var position = 0
    val len = input.length
    var ret = true
    loop@ while(position < len){
        for((w, l) in wl){
            if(position + l < len + 1 && input.substring(position, position + l) == w){
                position += l
                continue@loop
            }
        }
        ret = false
        break@loop
    }
    print(if(ret)"YES" else "NO")
}

Measured memory_bytes: 40680
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),d=read();
    if(n<10)d=d+100*(10-n);
    pr2(d);
    return 0;
}

Measured memory_bytes: 128
N = gets.to_i
e = Hash.new()
(N-1).times do
  a, b, c = gets.split(' ').map(&:to_i)
  e[a] ||= {}
  e[a][b] = c
  e[b] ||= {}
  e[b][a] = c
end

Q, K = gets.split(' ').map(&:to_i)
q = []
Q.times do
  q << gets.split(' ').map(&:to_i)
end

que = []
que << K

dist = []
dist[K] = 0
while !que.empty?
  cur = que.shift

  e[cur].each do |to, cost|
    if dist[to] == nil
      dist[to] = dist[cur] + cost
      que << to
    end
  end
end

q.each do |qi|
  print dist[qi[0]] + dist[qi[1]]
  print "\n"
end

Measured memory_bytes: 53168
N,K=map(  int,raw_input().split() )
X=map(  int,raw_input().split() )

ans=float("inf")
for l in range(N-K+1):
	r=l+K-1
	if X[l]<0:
		if X[r]<0:	
			ans=min(ans, abs(X[l]) )
		else:	
			ans=min(ans, 2*abs(X[l])+abs(X[r]) , abs(X[l])+2*abs(X[r]) )
	elif X[l]>=0 and X[r]>=0:
		ans=min(ans, X[r] )


print ans

Measured memory_bytes: 41700
N = int(input())
s_n = []
for i in range(N):
    s_n.append(input())
M = int(input())
for j in range(M):
    youso = input()
    if youso in s_n:
        s_n.remove(youso)
max_point = 0
for k in range(len(s_n)):
    max_point = [s_n.count(s_n[k]),max_point][s_n.count(s_n[k])<max_point]
print(max_point)

Measured memory_bytes: 3064
import sys


class SegTreeMin:

    def __init__(self, n, max_v):
        self.n = n
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [max_v] * (n2 << 1)
        self.INF = max_v

    def update(self, i, x):
        i += self.n2
        self.tree[i] = x
        while i > 1:
            self.tree[i >> 1] = x = min(x, self.tree[i ^ 1])
            i >>= 1

    def get_min(self, a, b):
        result = self.INF
        q = [(1, 0, self.n2)]
        while q:
            k, l, r = q.pop()

            if a <= l and r <= b:
                result = min(result, self.tree[k])
                continue

            m = (l + r) // 2
            k <<= 1
            if a < m and l < b:
                q.append((k, l, m))
            if a < r and l < m:
                q.append((k + 1, m, r))

        return result


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    seg_tree = SegTreeMin(n, 10 ** 15)
    seg_tree.update(0, 0)
    lrc = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    lrc.sort()
    for l, r, c in lrc:
        l -= 1
        r -= 1
        tm = seg_tree.get_min(l, r)
        seg_tree.update(r, min(tm + c, seg_tree.get_min(r, r + 1)))
    mt = seg_tree.get_min(n-1, n)
    print(mt if mt != 10 ** 15 else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 68828
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
a = I()
if (n%500) <= a:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3436
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val (n, z, w) = sc.intList()
        val a = sc.intList()

        // 全部
        val aa = Math.abs(a[n - 1] - w)
        val bb = if (n >= 2) Math.abs(a[n - 1] - a[n - 2]) else 0

        println(Math.max(aa, bb))
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

Measured memory_bytes: 38468
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(ll i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(ll i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<ll, ll> II;
typedef vector<II> vi;

int n, k, f[30], res;
map<string, bool> ma;
string s;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> n >> k;
    FOR(i,1,n) {
        cin >> s;
        if (ma[s] == false) {
            f[s[0]-'A']++;
            ma[s] = true;
        }
    }
    while (1) {
        int r = k;
        sort(f,f+26);
        FORE(i,25,0)
            if (f[i]) {
                r--;
                f[i]--;
                if (r == 0) break;
            }
        if (r) break;
        else res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    char a;
    cin>>a;
    if(a<'a')
        cout<<'A'<<endl;
    else
        cout<<'a'<<endl;
    return 0;
}

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

using namespace std;

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

  string s;
  cin >> s;
  int q;
  cin >> q;
  string t;
  rep(qi, q)
  {
    int ty;
    cin >> ty;
    if (ty == 1) {
      swap(s, t);
    }
    else if (ty == 2)
    {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        t += c;
      } else if (f == 2) {
        s += c;
      }
    }
  }
  reverse(t.begin(), t.end());
  t += s;
  cout << t << endl;
}


Measured memory_bytes: 1144
#include<iostream>
using namespace std;
int main(){
    long long int i,j,a,b,n=0,x,c,d;
    cin>>a;
    cin>>b;
    cin>>x;
    c=a/x;
    if(a>c*x){
        n++;
    }
    d=b/x;

    cout<<d-c-n+1;

    return 0;
}


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

int main(void)
{
	int stu[30];
	int i, j;
	
	memset(stu, 0, sizeof(stu));
	for (i = 0; i < 28; i++){
		int a;
		scanf("%d", &a);
		stu[a - 1] = 1;
	}
	
	for (i = 0; i < 30; i++){
		
		if (stu[i] == 0){
			printf("%d\n", i + 1);
		}
	}
	
	return (0);
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    ll has = 1000;
    int n;
    cin>>n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }

    reverse(a.begin(), a.end());

    ll buy = 1e9;

    while (a.size()) {
	ll x = a.back();
	a.pop_back();
	if (x<=buy) {
	    buy = x;
	} else {
	    ll afford = has/buy;
	    ll profit = x-buy;
	    has += profit*afford;
	    buy = x;
	}
    }

    cout<<has<<endl;    
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << a - b + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int n,b[100003];
int a[100003];
long long sum;
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(int i=0;i<n;i++)
{
	cin>>a[i];
}
sort(a,a+n);
if(!(n&1))
{
	for(int i=0;i<n/2-1;i++)
	{
		sum+=(long long)(a[n-1-i]*2-a[i]*2);
	}
	sum+=(long long)(a[n/2]-a[n/2-1]);
	cout<<sum<<endl;
	return 0;
}
for(int i=0;i<n/2-1;i++)
{
	sum+=(long long)(a[n-1-i]*2-a[i]*2);
}
sum+=max((long long)(2*a[n/2+1]-a[n/2]-a[n/2-1]),(long long)(a[n/2+1]+a[n/2]-2*a[n/2-1]));
cout<<sum<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 640
/**
 *    author:  RM07
 *    created: August 29, 2020 5:34 PM
 *    motto: Knowledge is Power, Strive for Excellence
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    string s, t;
    cin >> s >> t;
    int sLength = s.length();
    int tLength = t.length();
    int minimum = INT_MAX;
    for(int i = 0 ; i <= sLength - tLength; i++) {
        int toChange = 0;
        for(int j = 0 ; j < tLength; j++) {
            if(s[i + j] != t[j]) {
                toChange++;
            }
        }
        minimum = min(minimum, toChange);
    }
    cout << minimum << endl;
}

Measured memory_bytes: 3636
n, m = map(int, input().split())
a = list(map(int, input().split()))

n_use = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [0]+[-float('inf')]*n

for i in range(1, n+1):
    for a_j in a:
        i_prev = i - n_use[a_j]
        if i_prev < 0:
            continue
        else:
            dp[i] = max(dp[i], dp[i_prev]*10+a_j)
# print(dp)
print(dp[-1])


Measured memory_bytes: 14388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll same[10][10];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        ll l=i%10;
        if(l!=0)
        {
            ll f=i;
            while(f>=10)
            {
                f/=10;
            }
            same[f][l]+=1;
        }
    }
    ll ans=0;
    for(ll i=1;i<=9;i++)
    {
        ans=ans+same[i][i]*same[i][i];
    }
    for(ll i=1;i<=9;i++)
    {
        for(ll j=i+1;j<=9;j++)
        {
            if(i!=j)
            {
                ans=ans+2*same[i][j]*same[j][i];
            }
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
   int w,h,x,y,r;
   scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
   if(0<=x-r && 0<=y-r && x+r<=w && y+r<=h)
      printf("Yes\n");
   else
      printf("No\n");
   return 0;
}



Measured memory_bytes: 2052
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <iostream>
#include <limits>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
typedef stringstream ss;
const int mii = numeric_limits<int>::min();
const int mai = numeric_limits<int>::max();
const ll mil = numeric_limits<long long>::min();
const ll mal = numeric_limits<long long>::max();

#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 PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

int main(int argc, char **argv) {
    int k, n;
    cin >> k >> n;

    vi v(n, 0);

    REP(i, 0, n - 1) {
        cin >> v[i];
    }

    set<int> intervals;
    REP(i, 0, n-1) {
        if(i == n-1)
            intervals.insert(k-v[i] + v[0]);
        else
            intervals.insert(v[i+1] - v[i]);
    }

    cout << k - *(--intervals.end());

    return 0;
}

Measured memory_bytes: 1024
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    ans = 0
    for i in range(1,N+1):
        if not ((i%3==0) or (i%5==0)):
            ans += i
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10604
# solution

import io
import sys
import math

data = int(input())

array = [list(map(int, input().split())) for _ in range(data-1)]

for i in range(data-1):
    counter = 0
    for j in range(i, data-1):
        if counter < array[j][1]:
            counter = array[j][1]
        elif counter % array[j][2] != 0:
            counter += array[j][2] - (counter % array[j][2])
 
        counter += array[j][0]
 
    print(counter)
print(0)

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

signed main() {
  int X;
  cin >> X;
  
  int kazu = X / 100;
  X -= kazu*100;
  if( X > kazu*5 ){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
}

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

int main(){
  char A, B;
  cin >> A >> B;
  if((A == 'H' && B == 'H')||(A == 'D' && B == 'D'))
    cout << 'H' << endl;
  else
    cout << 'D' << endl;
}


Measured memory_bytes: 256
/*input
1000 1 1000
*/
 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <tgmath.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<long long, long long> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
 
#define M(x) ((x)%(1000000007))
 
vector<int> adj_list[100010];
bool visited[10010];

void dfs(int node){
	visited[node] = true;
	for(int n: adj_list[node]){
		if(!visited[n]){
			dfs(n);
		}
	}
}



int main() {
 	int n;
 	int x;
 	int t;
 	cin>>n>>x>>t;
 	int ans = ceil(n*1.0/x)*t;

 	cout<<ans<<endl;
}



 


Measured memory_bytes: 5984