akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int N;
long long A[3];

int main() {
    while (cin >> N) {
        for (int i = 0; i < 3; ++i) cin >> A[i];
        vector<long long> B(N);
        for (int i = 0; i < N; ++i) cin >> B[i];

        long long res = 1LL<<60;
        for (int bit = 1; bit < (1<<N); ++bit) {
            for (int bit2 = 1; bit2 < (1<<N); ++bit2) {
                if (bit2 & bit) continue;
                for (int bit3 = 1; bit3 < (1<<N); ++bit3) {
                    if (bit3 & bit) continue;
                    if (bit3 & bit2) continue;

                    long long a1 = 0, n1 = 0;
                    for (int i = 0; i < N; ++i) if (bit & (1<<i)) a1 += B[i], ++n1;
                    
                    long long a2 = 0, n2 = 0;
                    for (int i = 0; i < N; ++i) if (bit2 & (1<<i)) a2 += B[i], ++n2;

                    long long a3 = 0, n3 = 0;
                    for (int i = 0; i < N; ++i) if (bit3 & (1<<i)) a3 += B[i], ++n3;

                    long long tmp = abs(a1 - A[0])
                        + abs(a2 - A[1]) + abs(a3 - A[2])
                        + (n1 - 1) * 10 + (n2 - 1) * 10 + (n3 - 1) * 10;
                  
                    chmin(res, tmp);
                }
            }
        }
        cout << res << endl;
    }
}
                                                                          
 
                                             






Measured memory_bytes: 256
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    # n,m の先行受け取り
    n,m = map(int, input().split())
    # コンテナの準備
    k=[0 for i in range(m)]     # それぞれの電球(light)に繋がれたスイッチ(swuitch)の個数を表す
    # s=[0 for i in range(n)]     # それぞれの電球(light)に繋がれている「スイッチ(switch)」を表す
    
    S=[ [] for i in range(m)]
    # for i in range(m):
    #     S[i]=[ 0 for i in range( k[i] ) ]

    # 入力
    for i in range(m):
        l = list(map(int, input().split()))
        k[i] = l[0]
        ll=l[1:]
        for j in range(len(ll)):
            ll[j]=ll[j]-1
        S[i] = ll
    p = list(map(int, input().split()))

    # 出力
    eprint()
    # print(n,m)
    eprint("num of Switch : " + str(n) + "    num of Light : " + str(m))
    for i in range(m):
        # print(k[i],S[i])
        eprint("k[%d]: %d      S[%d]: " % (i,k[i],i ) + str(S[i]) )
    eprint("p: "+ str(p))

    # 処理
    cnt_state_whereLightIsTurnedOn=0
    
    for state in range(2**n):   # stateは状態(ステート)を表す整数
        failure_flag=0
        for index in range(m):  # indexは電灯の番号を表すインデックス
            cnt=0
            for i in range(k[index]): # i is the "uniform_number" of Switches
                if (state>>S[index][i] & 1)==1 :
                    cnt+=1
                    
            if cnt%2==p[index]:
                # failure_flag=0
                # cnt_state_whereLightIsTurnedOn+=1
                continue
            else:
                failure_flag=1
                break
                # eprint(cnt_state_whereLightIsTurnedOn)
        if failure_flag==0:
            cnt_state_whereLightIsTurnedOn+=1
        else:
            continue
        
    print(cnt_state_whereLightIsTurnedOn)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 68332
# coding: utf-8
# Your code here!

import copy

N = int(input())

U = []
D = []
R = []
L = []

for _ in range(N):
    x, y, ori = input().rstrip().split(' ')
    x = int(x)
    y = int(y)
    if ori == 'U':
        U.append([x, y])
    elif ori == 'D':
        D.append([x, y])
    elif ori == 'R':
        R.append([x, y])
    else:
        L.append([x, y])
      

def calc(inc_points, dec_points, other_points, index):
    inc = []
    dec = []
    other = [] 
    if len(inc_points) > 0:
        inc_min = min([x[index] for x in inc_points])
        inc_max = max([x[index] for x in inc_points])
        inc = [inc_min, inc_max]
    if len(dec_points) > 0:
        dec_min = min([x[index] for x in dec_points])
        dec_max = max([x[index] for x in dec_points])
        dec = [dec_min, dec_max]
    if len(other_points) > 0:
        other_min = min([x[index] for x in other_points])
        other_max = max([x[index] for x in other_points])
        other = [other_min, other_max]
       
    cross_time = [0]
    if len(inc_points) > 0 and len(dec_points) > 0:
        for u in [inc_min, inc_max]:
            for d in [dec_min, dec_max]:
                if u < d: # collision
                    cross_time.append((d - u) / 2)
                    
    if len(dec_points) > 0 and len(other_points) > 0:
        for rl in [other_min, other_max]:
            for d in [dec_min, dec_max]:
                if rl < d: # collision
                    cross_time.append(d - rl)
                    
    if len(inc_points) > 0 and len(other_points) > 0:
        for rl in [other_min, other_max]:
            for u in [inc_min, inc_max]:
                if u < rl: # collision
                    cross_time.append(rl - u)
                   
    return inc, dec, other, cross_time
    
def calc_size(inc, dec, other, times):
    sizes = []
    for time in times:
        values = copy.copy(other)
        if len(inc) > 0:
            values.extend([x + time for x in inc])
        if len(dec) > 0:
            values.extend([x - time for x in dec])
        sizes.append(max(values) - min(values))
    return sizes
   
inc_x, dec_x, other_x, cross_time_x = calc(R, L, U+D, 0)         
inc_y, dec_y, other_y, cross_time_y = calc(U, D, R+L, 1)

times = list(set(cross_time_x + cross_time_y))
sizes_x = calc_size(inc_x, dec_x, other_x, times)
sizes_y = calc_size(inc_y, dec_y, other_y, times)

print(min([x*y for x, y in zip(sizes_x, sizes_y)]))

Measured memory_bytes: 73048
sum_value = 0
max_value = 0
min_value = 0
count = 0
while True:
    count += 1
    if count == 1:
        n = int(input())
    if count == 2:
        a = map(int, input().split())
        for i, item in enumerate(a):
            if i == 0:
                max_value, min_value = item, item
            sum_value += item
            if max_value < item : max_value = item
            if min_value > item : min_value = item
        print (f'{min_value} {max_value} {sum_value}')
        break


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, rating;
    cin >> n >> rating;
    if (n >= 10) {
        cout << rating << endl;
    } else {
        cout << rating + 100 * (10 - n) << endl;
    }
}


Measured memory_bytes: 256
import numpy as np
MOD = 998244353

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

def gcd(a, b):
    if a > b:
        a, b = b, a
    if b % a == 0:
        return a
    return gcd(b % a, a)

N, A, B, K = map(int, input().split())

if A < B:
    A, B = B, A

# n = 2 * min(K // A + 2, N + 1) + 3
n = min((K + A - 1) // A, N) + 1
lcm = A * B // gcd(A, B)
step = lcm // A

c = Factorial(N + 1, MOD).comb #O(N)

def calc(a, b):
    if a > b:
        a, b = b, a #必ずaのほうが小さくなる
    return (c(N, a) * c(N, b)) % MOD


def count(a, b):
    if a <= N and b <= N:
        return calc(a, b)
    return 0

def maike_satrt(step):
    for i in range(step):
        if (K - A * i) % B == 0:
            return i

start = maike_satrt(step)
# print (start, n)
ans = 0
for a in range(start, n, step): #Aの数
    if A * a > K:
        break
    # if (K - A * a) % B != 0:
    #     continue
    b = (K - A * a) // B
    # print ('a=', a, 'b=', b)
    ans += count(a, b)
    ans %= MOD

print (ans)

Measured memory_bytes: 42948
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto X = RD;
	auto Y = RD;
	long ans;
	if (X == 3)
		ans += 100000;
	else if (X == 2)
		ans += 200000;
	else if (X == 1)
		ans += 300000;
	if (Y == 3)
		ans += 100000;
	else if (Y == 2)
		ans += 200000;
	else if (Y == 1)
		ans += 300000;
	if (X == 1 && Y == 1)
		ans += 400000;

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

if H > W:
  if N % H == 0:
    print(N//H)
  else:
    print(N//H +1)
else:
  if N % W == 0:
    print(N//W)
  else:
    print(N//W + 1)
  

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define VI vector<int>
#define VII vector<pair<int, int>>
#define PII pair<int, int>
#define MP make_pair
// #define log(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define log(fmt, ...)
// #define check(...) assert(##__VA_ARGS__)
#define check(...)

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

    int k;
    cin >> k;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1];
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int num = 10001, num1 = 101;
int dp[num];
int w[num1], v[num1];
int n, W;
int main() {
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> v[i] >> w[i];
	for (int i = 0; i < n; i++)
		for (int j = w[i]; j <= W; j++) {
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	cout << dp[W] << endl;
	return 0;
}

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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if( a == 1 && b == 1 )
    cout << "Draw" << endl;
  else if( a == 1 )
    cout << "Alice" << endl;
  else if( b == 1 )
    cout << "Bob" << endl;
  else if( a > b )
    cout << "Alice" << endl;
  else if( a < b )
    cout << "Bob" << endl;
  else
    cout << "Draw" << endl;
  return 0;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 10;

ll k, a[51];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> k;
    ll n = 50; //force
    for1(i, n)
    {
        a[i] += n - 1;
    }
    ll m = k % n;
    for1(i, n)
    {
        a[i] += k / n;
    }
    for1(i, m)
    {
        a[i] = a[i] + n - (m - 1);
    }
    fore(i, m + 1, n)
    {
        a[i] = a[i] - m;
    }
    cout << n << "\n";
    for1(i, n)
    {
        cout << a[i] << " ";
    }
    return 0;
}


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

int main(){
	int n, y, i = 0, j = 0;
	cin >>  n >> y;
	y /= 1000;

	for(i=0; i <= n; i++){
		for(j=0; j <= n-i; j++){
			int c = 9*i + 4*j + n;
			if(c==y && n-i-j>=0){
				cout << i << " " << j << " " << n-i-j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
'use strict'

let rect = [];

function Main(input) {
    const d = input.split('\n').map(v => v.split(' '));
    let s = d.shift();
    const W = Number(s[0]);
    const H = Number(s[1]);
    const N = Number(s[2]);

    rect = [];
    for (let i = 0; i < H; i++) {
        for (let j = 0; j < W; j++) {
            rect[i] = Array(W).fill(0);
        }
    }
    for (let i = 0; i < N; i++) {
        switch (Number(d[i][2])) {
            case 1:
                draw(0, d[i][0], 0, H);
                break;
            case 2:
                draw(d[i][0], W, 0, H);
                break;
            case 3:
                draw(0, W, 0, d[i][1]);
                break;
            case 4:
                draw(0, W, d[i][1], H);
                break;
            default:
                break;
        }
    }

    let result = 0;
    for (const arr of rect) {
        for (const v of arr) {
            if (v === 0) {
                result++
            }
        }
    }

    console.log(result);
}

function draw(xStart, xEnd, yStart, yEnd) {
    for (let y = yStart; y < yEnd; y++) {
        for (let x = xStart; x < xEnd; x++) {
            rect[y][x] += 1;
        }
    }
}


Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  string s, p;
  getline(cin, s);
  getline(cin, p);
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < p.size(); j++) {
      auto k = i + j;
      if (k >= s.size()) k -= s.size();
      if (s.at(k) != p.at(j)) break;
      if (j == p.size() - 1) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  cout << max(C - (A-B),0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using namespace std;

int main(){
  int n,m;
  cin >> n >>  m;
  int p[m];
  string s[m];
  REP(i,m) cin >> p[i] >> s[i];
  int w[n];
  REP(i,n) w[i] = 0;
  int ans_p = 0;
  int ans_s = 0;
  int num;
  bool ac[n];
  REP(i,n) ac[i] = false;
  
  REP(i,m){
    if(s[i] == "WA") w[p[i]-1]++;
    else if(!ac[p[i]-1]){
      ac[p[i]-1] = true;
      ans_p++;
      ans_s += w[p[i]-1];
    }
  }
  
  cout << ans_p << " " << ans_s;
  return 0;
}

Measured memory_bytes: 6528
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>


using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;



int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, A, B;
    cin >> N >> A >> B;

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

    ll ans = 0;
    FOR(i, 1, N) {
        ans += min((X[i] - X[i-1]) * A, B);
    }

    cout << ans << endl;
    
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  i64 a, b, c, d;
  cin >> a >> b >> c >> d;
  auto f = [&](i64 x) {
    i64 ret = x;
    ret -= x / c;
    ret -= x / d;
    ret += x / lcm(c, d);
    return ret;
  };
  cout << f(b) - f(a - 1) << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
int calcnum(int i,int j){
  if(i>j)swap(i,j);
  return i*N+j;
}
int A[1001][1001];
vector<P> es;
vector<int> g[1000*1000];
int ing[1000*1000];
int col[1000*1000];

bool dfs(int v){
  col[v]=1;
  for(int nv : g[v]){
    if(col[nv]==2)continue;
    if(col[nv]==1)return true;
    if(dfs(nv))return true;
  }
  col[v]=2;
  return false;
}

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

  cin>>N;
  rep(i,N){
    rep(j,N-1){
      cin>>A[i][j];
      A[i][j]--;
    }
    rep(j,N-2){
      es.push_back(P(calcnum(i,A[i][j]),calcnum(i,A[i][j+1])));
    }
  }
  sort(all(es));
  uni(es);

  rep(i,es.size()){
    g[es[i].fi].push_back(es[i].se);
    ing[es[i].se]++;
  }

  rep(i,N*N){
    if(col[i]==2)continue;
    if(dfs(i)){
      cout<<-1<<endl;
      return 0;
    }
  }

  vector<int> crt;
  rep(i,N*N){
    if(ing[i]==0){
      crt.push_back(i);
    }
  }
  int res=0;
  while(crt.size()){
    res++;
    vector<int> nxt;
    rep(i,crt.size()){
      int v=crt[i];
      for(int nv : g[v]){
        ing[nv]--;
        if(ing[nv]==0){
          nxt.push_back(nv);
        }
      }
    }
    crt=nxt;
  }
  cout<<res<<endl;

  return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    vector<int> a(n+1);
    for (int i = 2; i <= n; i++) {
        int ai; cin >> ai;
        ++a[ai];
    }
    for (int i = 1; i <= n; i++) {
        cout << a[i] << '\n';
    }
}



Measured memory_bytes: 3996
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: i128,
        b: i128,
        k: i128
    };

    let mut a = a;
    let mut b = b;
    let mut k = k;

    if a > 0 {
        if a > k {
            a = a - k;
            k = 0;
        } else {
            k = k - a;
            a = 0;
        }

        b = if b > k { b - k } else { 0 }
    } else if b > 0 {
        b = if b > k { b - k } else { 0 }
    }

    println!("{} {}", a, b)
}


Measured memory_bytes: 2120
def solve():
	n,m,*t=map(int,open(0).read().split())
	r=sorted([(b,a)for a,b in zip(*[iter(t)]*2)])
	c=bef=0
	for b,a in r:
		if a>bef:
			c+=1
			bef=b-1
	print(c)
if __name__=="__main__":solve()

Measured memory_bytes: 25132
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<memory.h>
#include<map>
#include<set>
#include<queue>
#include<math.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long LL;
int a[200005],n;
LL sum=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i),a[i]-=i;
	sort(a+1,a+1+n);
	int hh=a[(n+1)/2];
	for(int i=1;i<=n;i++)sum+=abs(a[i]-hh);
	printf("%lld",sum);
}


Measured memory_bytes: 896
#include<iostream>

using namespace std;
using ll = long long;
int main(void){
    ll n,a,b;
    cin >> n >> a >> b;
    ll x[n];
    for(ll i=0;i<n;i++)cin >> x[i];

    ll ans=0;
    for(ll i=0;i<n-1;i++){
        ans += min((x[i+1]-x[i])*a,b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	string S, T;
	cin >> S >> T;

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

	string U;
	cin >> U;

	if (S == U) {
		cout << A - 1 << " " << B << endl;
	}
	else {
		cout << A << " " << B - 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
double v[50],ans;

int main(void){
    cin >> N;
    for(int i=0;i<N;i++)cin>>v[i];
    sort(v,v+N);
    ans = v[0];
    for(int i=0;i<N;i++){
        ans = (ans+v[i])/2;
    }
    cout << fixed << setprecision(6);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n, a;
double h, t;

int main(){
  ios_base::sync_with_stdio(false);
  
  int ans = 0;
  double temp = (1 << 30);

  cin >> n >> t >> a;
  for(int i=0;i<n;i++){
    cin >> h;
    double b = h * 0.006;
    b = t - b;
    if(fabs(a - b) < fabs(a - temp)){
      temp = b;
      ans = i + 1;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        int[] num1 = new int[3000];
        int[] num2 = new int[3000];
        int i = 0;
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');


            num1[i] = int.Parse(str[0]);


            num2[i] = int.Parse(str[1]);


            if ((num1[i] == 0) && (num2[i] == 0))
            {
                break;
            }
            else
            {
                i++;
            }
        }

        for (int z = 0;z <= (i - 1);z++)
        {
            if (num1[z] >= num2[z])
            {
                Console.WriteLine("{0} {1}", num2[z], num1[z]);
            }
            else
            {
                Console.WriteLine("{0} {1}", num1[z], num2[z]);
            }
        }
    }
}

Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

    vector<ll> arr(n);
    ll count[64][2] = { 0 };
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];

        for (ll j = 0; j < 61; j++) {
            count[j][((arr[i] >> j) & 1) == 1]++;
        }
    }

    ll ans = 0;
    for (ll i = 0; i < 60; i++) {
        ans = ((ans + ((count[i][1] * count[i][0]) % mod) * ((1ll << i) % mod)) % mod);
    }

    cout << ans << endl;

}

/*
1 2 3
001
010
011

2 + 4
*/

Measured memory_bytes: 2688
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



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

    rep(i,0,sz(s)/2){
	if(s[i] != s[sz(s)-1-i]){
	    No;
	    ret 0;
	}
    }
  
    string ss = s.substr(0,sz(s)/2);

     rep(i,0,sz(ss)/2){
	if(ss[i] != ss[sz(ss)-1-i]){
	    No;
	    ret 0;
	}
    }

     ss = s.substr((sz(s)+3)/2 - 1);
   
     rep(i,0,sz(ss)/2){
	if(ss[i] != ss[sz(ss)-1-i]){
	    No;
	    ret 0;
	}
    }

     Yes;
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<queue>
#include <algorithm>
using namespace std;
int dxg[4] = {1, 0, -1, 0};
int dyg[4] = {0, 1, 0, -1};
 
int bfs(vector<vector<int> > &maze, int x,int y){
	int H=maze.size(), W=maze[0].size();
	vector<vector<int> > dist(H,vector<int>(W,-1));
	queue<pair<int,int> > que;
	int res=0;
	que.push({x,y});
	dist[x][y]=0;
	while(!que.empty()){
		x=que.front().first,y=que.front().second;
		res=max(res,dist[x][y]);
      	//cout<<res<<endl;
		que.pop();
		for(int i=0; i<4; i++){
			int nx=x+dxg[i],ny=y+dyg[i];
			if(nx<0||nx>=H || ny>=W|| ny<0) continue;
			if(maze[nx][ny]=='#')           continue;
			if(dist[nx][ny]==-1){
				dist[nx][ny]=dist[x][y]+1;
				que.push({nx,ny});
			}
		}
	}
	return res;
}


int main(int argc, char *argv[]){
  
  int dx,dy; cin>>dx>>dy;
  vector<vector<int> > maze(dx,vector<int>(dy));
  char status;
  for(int i=0;i<=dx-1; i++){
    for(int j=0; j<=dy-1; j++){
      cin>>status;
      maze[i][j]=status;
    
    }
  }
  int res=0;
  for(int i=0; i<=dx-1; i++){
	for(int j=0; j<=dy-1; j++){
      if(maze[i][j]=='#') continue;
      res=max(res,bfs(maze,i,j));
  }
  }
  cout<<res<<endl;
}

    
    
    
    
    


Measured memory_bytes: 256
main = do
    [sx_, sy_, tx_, ty_] <- return . map read . words =<< getLine
    let
	dx = tx_ - sx_
	dy = ty_ - sy_
	up = replicate dy 'U'
	right = replicate dx 'R'
	left = replicate (dx+1) 'L'
	down = replicate (dy+1) 'D'
	urPass = up++right++"U"++left++down++"R"
	ruPass = right++up++"R"++down++left++"U"
    putStr $ urPass++ruPass

Measured memory_bytes: 1148
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int conv[] = {0, 1, 2, 3, 5, 7, 8, 9};
int main () {
	ll n;
	while (cin >> n, n) {
		vector<int> oct;
		while (n >= 8) {
			oct.push_back(n % 8);
			n /= 8;
		}
		oct.push_back(n);
		for (vector<int>::reverse_iterator it = oct.rbegin(); it != oct.rend(); ++it) {
			cout << conv[*it];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=0;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli data[100100];
bool vis[100100];
string s;

#define R 0
#define L 1

lli func(lli dir,lli now){
	if(dir==R){
		if(s.at(now)=='L')return now;
		else{
			if(vis[now])return data[now];
			else{
				vis[now] = true;
				return data[now] = func(dir,now+1);
			}
		}
	}
	else{
		if(s.at(now)=='R')return now;
		else{
			if(vis[now])return data[now];
			else{
				vis[now] = true;
				return data[now] = func(dir,now-1);
			}
		}
	}
}
lli ans[100100];

signed main(){

	cin>>s;

	REP(i,0,s.size()){
		if(vis[i])continue;
		if(s.at(i)=='R')func(R,i);
		else func(L,i);
		//func(s.at(i)=='R'?R:L,i);
	}

	//収束先との差が偶数ならその場所、違う場合は1個手前になる。
	REP(i,0,s.size()){
		lli diff = abs(i-data[i]);
		if(diff%2){
			if(s.at(i)=='R')data[i]--;
			else data[i]++;
		}
		ans[data[i]]++;
	}
	REP(i,0,s.size())cout<<ans[i]<<" ";
	cout<<endl;


	return 0;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

struct UnionFind{
    vector<int> par;
    int count;
    UnionFind(int n) : par(n, -1), count(0){}
    int Find(int x){return par[x] < 0 ? x : Find(par[x]);}
    int Size(int x){return par[x] < 0 ? -par[x] : Size(par[x]);}
    bool Unite(int x, int y){
        x = Find(x);
        y = Find(y);
        if(x == y)
            return false;
        if(par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return ++count;
    }
};



signed main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(m), b(m);
    vector<int> c(k), d(k);
    for(int i = 0; i < m; ++i)
        cin >> a[i] >> b[i];
    for(int i = 0; i < k; ++i)
        cin >> c[i] >> d[i];
    vector<set<int>> edges(n);
    UnionFind uf(n);
    for(int i = 0; i < m; ++i){
        --a[i], --b[i];
        uf.Unite(a[i], b[i]);
        edges[a[i]].emplace(b[i]);
        edges[b[i]].emplace(a[i]);
    }
    for(int i = 0; i < k; ++i){
        --c[i], --d[i];
        edges[c[i]].emplace(d[i]);
        edges[d[i]].emplace(c[i]);
    }
    for(int i = 0; i < n; ++i){
        int res = 0;
        for(auto s : edges[i]){
            if(uf.Find(s) == uf.Find(i))
                ++res;
        }
        cout << uf.Size(i) - res - 1 << " \n"[i == n - 1];
    }
}


Measured memory_bytes: 28600
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    string s;
    ll dp1[maxn+1],dp2[maxn+1];
    ll mod = INF;
    
    cin >> s;
    
    dp1[0]=0;
    dp2[0]=1;
    
    for(int i=1;i<=s.size();i++){
        dp1[i]=dp1[i-1]*3%mod;
        if(s[i-1]=='1'){
            dp1[i]=(dp1[i]+dp2[i-1])%mod;
            dp2[i]=dp2[i-1]*2%mod;
        }else{
            dp2[i]=dp2[i-1];
        }
    }
    
    dp1[s.size()]=(dp1[s.size()]+dp2[s.size()])%mod;
        
    cout << dp1[s.size()]<<endl;
    
    return 0;
}


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

int main(){
    ll a,b,c,d,x,y,ans;
    cin>>a>>b>>c>>d;
    x=max(c,d);
    y=min(c,d);
    ll mod=x%y;
    while(mod!=0){
        x=y;
        y=mod;
        mod=x%y;
    }
    mod=y;
    ll bai=c/mod*d;
    a-=1;
    ans=b-a-((b/c-a/c)+(b/d-a/d)-(b/bai-a/bai));
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

signed main()
{
    int N;
    cin >> N;
    int ans = 0;
    REP(i, N) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

int main() {
  int K, X;
  cin >> K >> X;
  int max = std::min(1000000, X + K - 1);
  int min = std::max(-1000000, X - K + 1);
  for (int i = min; i <= max; ++i) {
    cout << i;
    if (i != max) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

using namespace std;
int main(){
	int i=0;
	string a;
	cin >> a;
	for(i=0;i<2; i++)
	{
		if(a[i] != a[i+1]){
			cout <<"Yes"<< endl;
			break;
		}
	}
	//cout << i << endl;
	if(i==2)
	{
		cout<<"No"<<endl;
	}

	return 0;
}

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

using namespace std;

int main(void) {
    string s;
    string t;
    int count = 0;
    cin >> s >> t;
    int tmp = s.size();
    for(int i = 0; i < tmp; i++){
        if(s.at(i) != t.at(i)){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)


typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}
                                                                                  
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  int n; cin >> n;
  vector<int> v(n) , c(n);
  int k = 0;
  forn(i , 0 , n) cin >> v[i];
  forn(i , 0 , n) cin >> c[i];
  //sort(v.begin() , v.end() , [](auto x , auto y){ return (x > y);});
  //sort(c.begin() , c.end() , [](auto x , auto y){ return (x > y);});
  forn(i , 0 , n) k += max(0 , v[i] - c[i]); 
  cout << k << endl;
   
                                                  
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		for(int i = 0 ; i < M ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for(int i = 1 ; i <= N ; i++) {
			int cnt = 0;
			for(int j = 0 ; j < M ; j++) {
				if(i == a[j] || i == b[j]) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int a,b,x;
int main() {
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b)) {
		cout<<"B"<<endl;
	}else if(abs(x-a)<abs(x-b)) {
		cout<<"A"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    long long N;
    scanf("%lld",&N);
    printf("%lld",(1000-N%1000)%1000);
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_L (100000)

string WORDS[4] = {"dream", "dreamer", "erase", "eraser"};
string S;

bool match(int n) {
  if (n == S.size()) return true;

  for (int i = 0; i < 4; i++) {
    string w = WORDS[i];
    bool flag = true;
    for (int j = 0; j < w.size(); j++) {
      if (n + j > S.size() || w[j] != S[n + j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      if (match(n + w.size())) return true;
    }
  }

  return false;
}

void solve() {
  if (match(0)) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
}

int main() {
  cin >> S;

  solve();
  
  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int A,B;
  cin>>A>>B;
  
  cout<<(A>(2*B)?A-2*B:0);
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a;
  cin>>a;
  for(int i=1;i<=9;i++)
  {
    for(int j=1;j<=9;j++)
    {
      if(a==i*j)
      {
       cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int c = 0, k;
    string s, ans;
    deque<char> q;
    cin>>s>>k;
    f(i,s.length())q.pb(s[i]);
    while(k--){
        int t;
        cin>>t;
        if(t == 1)c ^= 1;
        else{
            int f;
            char u;
            cin>>f>>u;
            if(c){
                if(f == 1)q.pb(u);
                else q.push_front(u);
            }
            else{
                if(f == 2)q.pb(u);
                else q.push_front(u);
            }
        }
    }
    if(c == 1){
        while(!q.empty()){
            ans.pb(q.back());
            q.pop_back();
        }
    }
    else{
        while(!q.empty()){
            ans.pb(q.front());
            q.pop_front();
        }
    }
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 1368
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define vi vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define INF 1e18
#define mod 1000000007
#define pb push_back
#define For(k,j) for(int i = k ;i < j ; ++i)
#define endl "\n"
using namespace std;

bool cmp(int a,int b){
	return a>b;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t=1;
	while(t--){
		int ar[3];
		For(0,3) cin>>ar[i];

		int five = 0, seven = 0;
		For(0,3){
			if(ar[i]==5) five++;
			if(ar[i]==7) seven++;
		}

		five==2&&seven==1 ? cout<<"YES\n" : cout<<"NO\n";
	}
	return 0;
}

Measured memory_bytes: 384