akhauriyash/Code-Regression huggingface dataset:
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();

const getAns = (K: bigint): number => {
  let cnt = 0;
  const hits = new Map<bigint, boolean>();

  let tmp = 7n;
  // eslint-disable-next-line no-constant-condition
  while (true) {
    cnt++;
    const r = tmp % K;

    if (r === 0n) return cnt;
    else if (hits.get(r)) return -1;

    hits.set(r, true);
    tmp = (10n * tmp + 7n) % K;
  }
};

{
  const K = biCin();
  const ans = getAns(K);
  console.log(ans);
}


Measured memory_bytes: 130276
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;




int main(){
    string s;
    cin>>s;
    vector<ll> count(256,0);
    ll ans=0;
    for(int i=0;i<s.size();i++){
        ans+=i;
        ans-=count[s[i]];
        count[s[i]]++;
    }
    ans++;
    cout<<ans<<endl;
    
    return 0;
}


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

int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  ll x = min(b-1,n);
  cout << floor(a*x/b) - (a*floor(x/b)) << endl;
  return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int N; cin >> N;
  stack<char> ans;
  int digit = 0, ascii;
  while(N){
    ascii = int(N % 26);
    if(ascii == 0) ascii += 26;
    ans.push(char(ascii + 96));
    N = (long int)((N - ascii) / 26);
    digit += 1;
  }
  for(int i = 0; i < digit; i++){
    cout << ans.top();
    ans.pop();
  }
  return 0;
}

Measured memory_bytes: 3564
//
/*
ID: kfoozmi1
LANG: C++
TASK:
*/
#include <bits/stdc++.h>
using namespace std;

#ifdef kfoozminus
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu() {
	cerr << endl;
}

template <typename T>
void faltu(T a[], int n) {
	for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename First, typename ... hello>
void faltu(First arg, const hello&... rest) {
	cerr << arg << ' ';
	faltu(rest...);
}
#else
#define dbg(args...)
#endif

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define SQR(a) ((a) * (a))
#define vsort(v) sort(v.begin(), v.end())
#define PQ priority_queue
#define PI acos(-1)
#define EPS 1e-9

#define B1 43
#define B2 43

#define MOD1 1000000007
#define MOD2 1000000009
#define MOD  1000000007

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~ (1LL << i)); }
inline bool EQ(double a, double b) { return fabs(a-b) < EPS; }
inline double dist(double ix, double iy, double jx, double jy) { return sqrt(SQR(ix - jx) + SQR(iy - jy)); }

#define PMX 1000000

int marked[PMX/64+2];

#define mark(x) marked[x>>6] |= (1<<((x&63)>>1))
#define check(x) (marked[x>>6] & (1<<((x&63)>>1)))

bool isPrime(int x)
{
    return (x>1) && ((x==2) || ((x&1) && (!(check(x)))));
}

void seive(int n)
{
    int i, j;
    for(i=3; i*i<=n; i+=2)
    {
        if(!check(i))
        {
            for(j=i*i; j<=n; j+=i<<1)
            {
                mark(j);
            }
        }
    }
}

ll bigMod(ll a, ll b)
{
	ll r = 1;
	while(b) {
		if(b & 1) (r *= a) %= MOD;
		b >>= 1;
		(a *= a) %= MOD;
	}
	return r;
}

#define INF 100000000
#define MX 100007

int main()
{
#ifdef kfoozminus
	//freopen("in", "r", stdin);
#endif
	ll ans = 0, n, x, a, b;
	scanf("%lld %lld", &n, &x);

	a = x;
	b = n - x;
	ans = x;
	bool f = 1;
	while(true) {

		if(a < b) {

			if(f) {
				ans += b;
				f ^= 1;
			}
			swap(a, b);
		}
		else {
			ans += (a/b) * 2 * b;
			a %= b;
			if(a == 0) {
				
				if(f == 0) ans -= b;
				break;
			}
		}
		dbg(ans);
	}
	printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <deque>
using namespace std;

vector<int> graph;
vector<bool> visited;

deque<long long> d;


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

    for(int i = 0; i < k; i++){
        graph.push_back(1 << 30);
        visited.push_back(false);
    }

    graph[1] = 0;
    d.push_back(1);
    //cerr << "int" << endl;
    //cerr << "init" << endl;
    while(!d.empty()){
        long long i = d.front();
        //cerr << i << endl;
        d.pop_front();
        if(visited[i%k]){
            continue;
        }
        visited[i%k] = true;

        graph[(i+1)%k] = min(graph[(i+1)%k], graph[i%k]+1);
        d.push_back((i+1)%k);
        
        graph[(i*10)%k] = min(graph[(i*10)%k], graph[i%k]);
        d.push_front((i*10)%k);
    }
    cout << graph[0]+1 << endl;

    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
 
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
 
const char newl = '\n';
 
using namespace std;
using ll = long long;
 
auto main() -> int
{
	cin.tie(0);
  	ios::sync_with_stdio(0);
    
	ll A; cin >> A;
    long double B; cin >> B;
    
    ll h = (A * ll(B * 100 + 0.5)) / 100;
    
    cout << h << newl;
    
    return 0;
}

Measured memory_bytes: 3700
/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 720720
#define yes cout << "Yes\n"
#define no cout << "No\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

const int N = 100005;

int c = 1;

void solve() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    take;
    ll ans = 0;
    for(int i = 1; i < n; i++) {
        ll s = a[i] + a[i - 1];
        if(s <= x) continue;
        s -= x;
        ans += s;
        a[i] = max(0LL, a[i] - s);
    }
    cout << ans << '\n';
    return;
}

int main() {
    /*int tc;
    scanf("%d", &tc);
    while(tc-- > 0)*/
    solve();
    return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
	string str;
	cin >> str;
	char c1 = '\0';
	char c2 = c1;
	for (int i = 0; i < str.length(); i++) {
		if (str.at(i) == c1) {
			cout << (i) << " " << (i + 1) << endl;
			return 0;
		}
		if (str.at(i) == c2) {
			cout << (i - 1) << " " << (i + 1) << endl;
			return 0;
		}
		c2 = c1;
		c1 = str.at(i);
	}
	cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
int dp[3010][3010];
int32_t main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        dp[i][i] = v[i];
    }
    for(int len=1;len<n;len++)
    {
        for(int i=0;i<n-len;i++)
        {
            int j=i+len;
            dp[i][j]=max(v[i]-dp[i+1][j],v[j]-dp[i][j-1]);
        }
    }
    cout<<dp[0][n-1];
    return 0;
}

Measured memory_bytes: 70016
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

#include <cstdio>

typedef long long ll;
using namespace std;

int main(void){
    
    char c;
    int sum;
    while(1){
        sum=0;
        while(1){
            scanf("%c",&c);
            if (c=='\n') break;
            sum+=(c-'0');

        }
        
        if (sum==0) break;
        cout<<sum<<endl;
    }

	return 0;
}


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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  cout << char(a[0] + 'A' - 'a') << char(b[0] + 'A' - 'a') << char(c[0] + 'A' - 'a') << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! printvec {
    ( $item:expr ) => {
        for &i in &$item {
            print!("{} ", i);
        }
        println!("");
    }
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        A: usize, B: usize
    }
    println!("{}", (A + B) % 24);
}

Measured memory_bytes: 4352
#include <iostream>
// #include <algorithm>

using namespace std;

bool dfs(int i, int left, int right, int* balls) {
    if(i == 10)
        return true;

    if(balls[i] > left && dfs(i+1, balls[i], right, balls))
        return true;

    if(balls[i] > right && dfs(i+1, left, balls[i], balls))
        return true;

    return false;
}

int main() {
    int N;
    int balls[10];
    cin >> N;
    while(N-- > 0) {
        for(int i = 0; i < 10; i++)
            cin >> balls[i];

        if(dfs(1, balls[0], 0, balls))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}


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

int main() {
    int64_t n, x, m;
    cin >> n >> x >> m;
    vector<int64_t> cnt(m, 0);
    queue<int64_t> rem;
    int64_t index = 1, sum = x, ans = 0, next = (x * x) % m,
            loop = 0;
    cnt[x] = index;
    rem.push(x);
    while (true) {
        if (cnt[next] != 0) break;
        cnt[next] = ++index;
        rem.push(next);
        sum += next, next = (next * next) % m;
    }
    for (auto i = 1; i < cnt[next]; i++) {
        ans += rem.front();
        rem.pop();
    }
    loop = rem.size(), n -= (cnt[next] - 1),
    ans += (n / loop) * (sum - ans);
    for (auto i = 0; i < n % loop; i++) {
        ans += rem.front();
        rem.pop();
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int enum_divisors(int N)
{
    vector<int> res;
    for (int i = 1; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N / i != i)
                res.push_back(N / i);
        }
    }
    return res.size();
}

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

    int ans(0);
    while(a<=b){
        a *= 2;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    double N, M, ans=0, sum=0;
    cin >> N >>M;
    vector<double> a(N);

    for(int i=0; i<N; i++){
	cin >> a[i];
	sum += a[i];
    }
    double tmp = sum/(4*M);

    sort(a.begin(), a.end(), greater<double>());

    bool flag = true;
    for(int i=0; i<M; i++){
	if(a[i]<tmp)
	    flag=false;
    }


    


    cout << (flag ? "Yes": "No") << endl;
} 




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

int main(){
  
  int N;
  cin>>N;
  vector<int> h(N), cst(N, 0);
  for(int i=0; i<N; i++) cin>>h[i];
  
  cst[0]=0; cst[1]=abs(h[1]-h[0]);
  for(int i=2; i<N; i++){
    cst[i]=min(cst[i-2]+abs(h[i]-h[i-2]), cst[i-1]+abs(h[i]-h[i-1]));
  }
  
  cout<<cst[N-1]<<endl;
  return 0;
}

Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;

int main(int argc, char* argv[]){

	int A,B,H,M;

	scanf("%d %d %d %d", &A, &B, &H, &M);

	double theta, alpha, beta, y;
	double pi = M_PI;

	alpha = double(M) * 2.0 * pi / 60.0;
	beta = (double(H)+double(M)/60.0) * 2.0 * pi / 12.0;
	theta = min(abs(alpha-beta), 2.0*pi-abs(alpha-beta));

	y = sqrt(pow(double(A), 2.0)+pow(double(B), 2.0) - 2.0 * double(A) * double(B)*cos(theta));
	printf("%.15lf\n", y);
	return 0;
}







Measured memory_bytes: 4292
#include<iostream>
#include<stdio.h>
#include<algorithm>

int main(){

	int a,b;

	scanf("%d%d",&a,&b);

	if(a <=0 && b >=0 )printf("Zero\n");


	if(a>0)printf("Positive\n");

	if(a<0){


		if(b < 0 && (a-b)%2 == 0) printf("Negative\n");

		if(b < 0 && (a-b)%2 == -1)printf("Positive\n");

	

	}



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll N;
    cin >> N;
    if(N%2 == 1){
        cout << 0 << "\n";
    }else{
        ll ans = 0;
        while(N){
            N /= 5;
            ans += N/2;
            //cout << ans << "\n";
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
class itp1_2d:
    def judge(self,W,H,x,y,r):
        if(x-r<0 or
           x+r>W or
           y-r<0 or
           y+r>H):
            print("No")
        else :
            print("Yes")
if __name__=="__main__":
    num=map(int,raw_input().split(" "))
    run=itp1_2d()
    run.judge(num[0],num[1],num[2],num[3],num[4])
    

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

int n, k;
vector<bool> d(10);

bool check(int n) {
    while (n != 0) {
        if (d[n % 10]) return false;
        n /= 10;
    }

    return true;
}

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

    int temp;
    for (int i = 0 ; i < k ; ++i) {
        cin >> temp;
        d[temp] = 1;
    }

    for (int i = n ; i <= 999999 ; ++i) {
        if (check(i)) {
            cout << i;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3628
def main():
    n = int(input())
    def dfs(s, c):
        chars = 'abcdefghijklmnop'
        if len(s) == n:
            print(s)
            return
        for i in range(c):
            dfs(s+chars[i], c)
        dfs(s+chars[c], c+1)
    dfs("", 0)

main()


Measured memory_bytes: 4340
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {


    private static void dfs(int i, ArrayList<Integer>[] map, int[] degree, int[] dist, boolean[] visited) {
        if(visited[i]) {
            return;
        }
        visited[i] = true;
        if(map[i] == null) {
            return;
        }
        for (Integer to : map[i]) {
            degree[to]--;
            dist[to] = Math.max(dist[i] + 1, dist[to]);
            if(degree[to] == 0) {
                dfs(to, map, degree, dist, visited);
            }
        }
    }
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] degree = new int[n+1];
        boolean[] visited = new boolean[n+1];
        int[] dist = new int[n+1];
        ArrayList<Integer>[] map = new ArrayList[n+1];
        for (int i = 0; i < m; i++) {
            int from = scanner.nextInt();
            int to = scanner.nextInt();
            if(map[from] == null) {
                map[from] = new ArrayList<>();
            }
            map[from].add(to);
            ++degree[to];
        }

        for (int i = 0; i < n + 1; i++) {
           if(!visited[i] && degree[i] == 0) {
               dfs(i, map, degree, dist, visited);
           }
        }
        int max = 0;
        for (int i = 0; i < n + 1; i++) {
           max = Math.max(max, dist[i]);
        }
        System.out.println(max);
    }


}

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

using namespace std;

int main() {
  int N; cin >> N;
  int L[N];
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }

  sort(L, L + N);

  int ans = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L[i] + L[j] > L[k] && L[i] != L[j] && L[j] != L[k]) {
          // exists triangle
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}

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

typedef long long ll;

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

int main() {
	while(1) {
		int a[3][2];
		int flg = 0;
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 2; j++) {
				cin >> a[i][j];
				flg += a[i][j];
			}
		}
		if(!flg)
			break;
		ll res = 1;
		for(int i = 0; i < 3; i++) {
			ll b, j;
			j = 1, b = a[i][0];
			while(b != 1) {
				b = (b * a[i][0]) % a[i][1];
				j++;
			}
			res = lcm(res, j);
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1156
//#pragma comment(linker, "/STACK:36777216")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <sstream>
#include <vector>
#include <complex>
#include <ctime>
#include <stack>

//#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector< VI > VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define FOR(i, x, y) for(int i = (x); i <= (y); ++i)
#define RFOR(i, y, x) for(int i = (x); i >= (y); --i)
#define SZ(a) (int)(a).size()
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a)) 
#define CLEAR(x) memset(x, 0, sizeof x);
#define COPY(FROM, TO) memcpy(TO, FROM, sizeof TO);
#define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())
#define pb push_back
#define mk make_pair
#define sqr(x) ((x)*(x))
#define X first
#define Y second
//typedef tree<int, null_type, less<int>, 
//  rb_tree_tag, tree_order_statistics_node_update> order_set;

const long double PI = acos(-1.0);
const double EPS = 1E-6;
const int INF = 2 * (1e+9) + 1;
const int MAXN = 3 * 100000001;
const int MOD = (1e+9) + 7;


ll n, m, k;
string s;
int a[200100];
int cc[200100];
int main() {
    int nn = 0;
    //freopen("a.txt", "r", stdin);
    cin >> n;
    REP(i, n - 1) {
        cin >> a[i];
        cc[a[i] - 1]++;
    }
    REP(i, n) {
        cout << cc[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4728
H , W , K = map(int,input().split())
cake = [list(input()) for _ in range(H)]
strawberry = []
strawberry_num = 1
visited = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if cake[i][j] == "#":
            strawberry.append([i,j])
            visited[i][j] = strawberry_num
            strawberry_num += 1

for i in range(H):
    now = 0
    for j in range(W):
        if cake[i][j] == '#':
            now = visited[i][j]
        elif now != 0 and cake[i][j] == "." and visited[i][j] == 0:
            visited[i][j] = now
    now = 0

    for j in range(W-1 , -1 , -1):
        if cake[i][j] == '#':
            now = visited[i][j]
        elif now != 0 and cake[i][j] == "." and visited[i][j] == 0:
            visited[i][j] = now


for i in range(1,H):
    if visited[i][0] == 0:
        visited[i] = visited[i-1]
for i in range(H-2,-1,-1):
    if visited[i][0] == 0:
        visited[i] = visited[i+1]
for i in visited:
    print(*i)


Measured memory_bytes: 58268
#include <stdio.h>

int main (){
	
    int k,a,b;
    int bisa = 0;
    
    scanf("%d", &k);
    
    scanf("%d %d", &a, &b);

    for(int i=a; i<=b; i++){
        if(i%k==0){
          bisa = 1;  
        }
        
    }
    if(bisa == 1){
        printf("OK\n");
    }
	else if(bisa == 0) {
        printf("NG\n");
    }
    
	return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e5+6;
void solve(){
	int a,b; 
	cin>>a>>b; 
	string s; 
	int n = a+b+1;
	cin>>s; 
	bool can = true;
	for(int i=0;i<a;i++){
		if(s[i]<='9' and s[i]>='0'){}
		else can = false;
	}
	for(int i=a+1;i<n;i++){
		if(s[i]<='9' and s[i]>='0'){}
		else can = false;
	}
	if(s[a]!='-')can = false;
	if(can)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>


void maxHeapify(int A[],int i,int H)
{
  int l,r,largest;
  int k=0;
  l=2*i;
  r=2*i+1;

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

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

  if(largest != i)
    {
      k=A[i];
      A[i]=A[largest];
      A[largest]=k;

      maxHeapify(A,largest,H);
    }
}

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

int main()
{
  int p=0;
  int a[1000000];
  int i;
  scanf("%d",&p);
  for(i=1;i<=p;i++)
    {
      scanf("%d",&a[i]);
    }
  buildMaxHeap(a,p);
  for(i=1;i<=p;i++)printf(" %d",a[i]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 3728
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_B() {}
#else

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;

    vl L(N + 1);
    L[0] = 2;
    L[1] = 1;
    FOR(i,2,N+1) {
        L[i] = L[i - 1] + L[i - 2];
    }

    ll ans = L[N];
    cout << ans << endl;

    return 0;
}

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

int n, m, dp[3002][3002];
string s, t, aux;

int main()
{
  cin >> s >> t;
  n = s.size();
  m = t.size();
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i == 0 || j == 0)
        dp[i][j] = 0;
      else if (s[i - 1] == t[j - 1])
        dp[i][j] = dp[i - 1][j - 1] + 1;
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
     }
  }
  //cout << dp[n][m];
  int i = n, j = m;
  while (i != 0 && j != 0) {
    if (s[i - 1] == t[j - 1]) {
      aux += s[i - 1];
      i--;
      j--;
      continue;
    }
    if (dp[i - 1][j] > dp[i][j - 1])
      i--;
    else
      j--;
  }
  for (int i = aux.size() - 1; i >= 0; i--)
    cout << aux[i];
  return 0;
}


Measured memory_bytes: 35456
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;
using ull = unsigned long long;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    return p1.second > p2.second;
}

void solve(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << fixed;
    cout << setprecision(10) << w*h/2 << " ";
    cout << (2*x==w && 2*y==h) << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a,b,c,d,A,B;
int main(void){
	cin>>n>>m>>a>>b>>c>>d;
	if((a-c)>0&&(b-d)>0){
		cout<<0<<endl;
		return 0;
	}
	if((a-c)<0&&(b-d)<0){
		cout<<0<<endl;
		return 0;
	}
	A=abs(a-c)*n;
	B=abs(b-d)*m;
	if(A==B){
		cout<<"infinity"<<endl;
		return 0;
	}
	if(A>B){
		cout<<0<<endl;
		return 0;
	}
	else {
		if(A%(B-A)==0){
			cout<<(A/(B-A))*2<<endl;
			return 0;
		}
		cout<<(A/(B-A))*2+1<<endl;
	}
}

Measured memory_bytes: 256
def finalLength(sample):
    foo = len(sample)
    tmp = 0
    for c in sample:
        if c=='S':
            tmp += 1
        elif tmp>0:
            tmp -= 1
            foo -= 2
    return foo

def main():
    sample = raw_input().strip()
    print finalLength(sample)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2948
X=int(input())
a=X//100
b=X%100
c=b%10
b=b//10
d=c%5
c=c//5
if d>0:
  e=1
else:
  e=0
temp=2*b+c+e
if temp>a:
  print(0)
else:
  print(1)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc;// = new Scanner(System.in);
        sc = new Scanner(System.in);
        int count = 0;
        int sum = 0;
        int r = sc.nextInt();
        int c = sc.nextInt();
        int data[][] = new int[r+1][c+1];
        for(int x = 0;x<r;x++){
            sc.nextLine();
            for(int y = 0;y<c;y++){
                data[x][y] = sc.nextInt();
                count += data[x][y];
            }
            data[x][c] = count;
            sum += count;
            count = 0;
        }
        data[r][c] = sum;
        for(int y = 0;y<c;y++){
            for(int x = 0;x<r;x++){
                count += data[x][y];
            }
            data[r][y] = count;
            count = 0;
        }

        for(int x = 0;x<=r;x++){
            for(int y = 0;y<=c;y++){
                if(y == 0){
                    System.out.print(data[x][y]);
                }else{
                    System.out.print(" "+data[x][y]);
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 46632
s = input()
plus = ''
ans = 0
if len(s) == 1:
    print(s)
else:
    for i in range(2**(len(s)-1)):
        for j in range(len(s)):
            plus += s[j]
            if ((i >> j) & 1):
                ans += int(plus)
                plus = ''
            if j == len(s) - 1 and len(plus) != 0:
                ans += int(plus)
                plus = ''
    print(ans)

Measured memory_bytes: 39792
N = int(input())
A = [int(x) for x in input().split()]

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義
    
list_gcd = [(gcd(A[0],A[1]),False),(A[0],True),(A[1],True)]
#print(list_gcd)

for i in range(2,len(A)):
    next_gcd = []
    for j in list_gcd:
        if j[1]:
            this_gcd = (gcd(j[0],A[i]),True)
            if not(this_gcd in next_gcd):
                next_gcd.append(this_gcd)
        else:
            this_gcd = (gcd(j[0],A[i]),False)
            if not(this_gcd in next_gcd):
                next_gcd.append(this_gcd)
                
            this_gcd = (j[0],True)
            if not(this_gcd in next_gcd):
                next_gcd.append(this_gcd)
    list_gcd = next_gcd
    #print(list_gcd)
         
out = 1
for i in list_gcd:
    if i[0] > out:
        out = i[0]
        
print(out)

Measured memory_bytes: 14052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli gcd(lli x, lli y) {
  while (x%y!=0) {
    lli t=y;
    y=x%y;
    x=t;
  }
  return y;
}

lli lcm(lli x, lli y) {
  return x/gcd(x,y)*y;
}

lli n, t[1000];
int main() {
  cin >> n; read_n(t, n);
  lli ans = 1;
  for (lli i=0; i<n; ++i) {
    ans = lcm(ans, t[i]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

const int MAXN = 1e5 + 19;

int n, m;

int fa[MAXN];
int getf(int node){
	return fa[node] == node ? node : fa[node] = getf(fa[node]);
}

int main(){
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	
	std::cin >> n >> m;
	for(int i = 1; i <= n; ++i) fa[i] = i;
	while(m--){
		int a, b;
		std::cin >> a >> b;
		if(getf(a) != getf(b))
			fa[getf(a)] = getf(b);
	}
	
	int cnt = 0;
	for(int i = 1; i <= n; ++i)
		if(getf(i) == i) ++cnt;
	std::cout << cnt - 1 << std::endl;
	return 0;
}

Measured memory_bytes: 4044
n = int(input())
s1 = input()
s2 = input()

mod = 10**9+7
yoko = True
if s1[0]==s2[0]:
    ans = 3
    cur = 1
    yoko = False
else:
    ans = 6
    cur = 2

while cur<n:
    if s1[cur]==s2[cur]:
        ans *= 1 if yoko else 2
        ans %= mod
        cur += 1
        yoko = False
    else:
        ans *= 3 if yoko else 2
        ans %= mod
        cur += 2
        yoko = True

print(ans)

Measured memory_bytes: 61976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}
/*
int main() {
  int V, E, R;
  scanf("%d %d %d", &V, &E, &R);
  WeightedGraph< int > g(V);
  for(int i = 0; i < E; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    g[a].emplace_back(b, c);
  }
  for(auto &dist : dijkstra(g, R)) {
    if(dist == numeric_limits< int >::max()) puts("INF");
    else printf("%d\n", dist);
  }
  }*/

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H,W;
  cin >> H >> W;
  string s[H];
  rep(i,H) cin >> s[i];
  WeightedGraph<int > g(H*W);
  rep(j,H){
    rep(i,W){
      if(i==0) continue;
      if(s[j][i]=='.' && s[j][i-1]=='.'){
	g[j*W+i-1].emplace_back(j*W+i,1);
	g[j*W+i].emplace_back(j*W+i-1,1);
       }
    }
  }
  rep(j,H){
    rep(i,W){
      if(j==0) continue;
      if(s[j][i]=='.' && s[j-1][i]=='.'){
        g[(j-1)*W+i].emplace_back(j*W+i,1);
        g[j*W+i].emplace_back((j-1)*W+i,1);
       }
    }
  }
  int ans=H*W;
  rep(j,H){
    rep(i,W){
      if(s[j][i]=='#') ans--;
    }
  }
  //  cout << ans << endl;
  int dist = dijkstra(g, 0)[H*W-1];
  //  cout << dist << endl;
  if(dist==numeric_limits< int >::max()) cout << -1 << endl;
  else   cout << ans-(dist+1) << endl;
    
  
  return 0;
    

}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		int m_1= sc.nextInt();
		int d_1= sc.nextInt();
		int m_2= sc.nextInt();
		int d_2= sc.nextInt();
		if(m_1!=m_2)
			System.out.println("1");
		else
			System.out.println("0");
	}
}

Measured memory_bytes: 21844
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

d=input().strip().split(" ")
e=[int(i) for i in d]

if (e[0] in a and e[1] in a):
    print("Yes")

elif e[0] in b and e[1] in b:
    print("Yes")

elif e[0] in c and e[1] in c:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M; cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    vector<bool> good(N, true);
    for (int i = 0; i < M; ++i) {
        int Ai, Bi;
        cin >> Ai >> Bi;
        if (H[Ai-1] <= H[Bi-1]) {
            good[Ai-1] = false;
        }
        if (H[Bi-1] <= H[Ai-1]) {
            good[Bi-1] = false;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (good[i])  ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N, M, ans=0, total=1;
  string s[110] = {""}, t[110];

  cin >> N;
  for(int i = 0; i < N; i++) cin >> s[i];

  cin >> M;
  for(int i = 0; i < M; i++) cin >> t[i];

  sort(s, s+N);
  sort(t, t+M);

  for(int i = 0; i < N; i++){

    if(s[i] == s[i+1]){
      total++;
      continue;
    }
    for(int j = 0; j < M; j++){
      if(s[i] == t[j]) total--;
    }
    if(ans < total) ans = total;
    total = 1;
  }
  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  char str[7];
  
  do{
    scanf("%s",str);
  } while(str[4] != 0 && str[6] != 0);
  
  if (str[2] == str[3] && str[4] == str[5]) 
    printf("Yes");
  else
    printf("No");
  
  return 0;
}
  

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

using namespace std;
const int N = 3e3 + 3, M = 33;
int a, b, c, d, e, f;

pair<int, int> memo[N][N];

pair<int, int> maxi(pair<int, int> a, pair<int, int> b) {
	auto A = a, B = b;
	a.first *= b.second;
	b.first *= a.second;
	b.second = a.second = a.second * b.second;
	if (a.first > b.first) {
		return A;
	} else {
		return B;
	}
}
pair<int, int> go(int water, int sugar) {
	if (water + sugar > f)
		return {-1e4, 1};
	pair<int, int> &ret = memo[water][sugar];
	if (~ret.first)
		return ret;
	ret = {-1e4, 1};
	if (sugar + water && (sugar + e - 1) / e * 100 <= water) {
		ret = {100 * sugar, water + sugar};
	}
	ret = maxi(ret, go(water + 100 * a, sugar));
	ret = maxi(ret, go(water + 100 * b, sugar));
	ret = maxi(ret, go(water, sugar + c));
	ret = maxi(ret, go(water, sugar + d));
	return ret;
}

int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//#endif
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	memset(memo, -1, sizeof memo);
	int sugar = go(0, 0).first / 100;
	int water = go(0, 0).second - sugar;
	printf("%d %d\n", sugar + water, sugar);
	return 0;
}



Measured memory_bytes: 70784
s = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)


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

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}


int main(){
  string S;
  cin >> S;
  vector<ll> T(S.size());
  T.at(0)=(S.at(S.size()-1)-'0');
  for(ll i=1;i<S.size();i++){
    T.at(i)=T.at(i-1)+(S.at(S.size()-i-1)-'0')*modPow(10,i);
    T.at(i)%=MOD;
  }
  sort(T.begin(),T.end());
  ll t=0,x=1,ans=0;
  for(ll i=0;i<S.size();i++){
    if(t==T.at(i)){
      x++;
    }else{
      ans+=(x*(x-1))/2;
      x=1;
      t=T.at(i);
    }
  }
  ans+=(x*(x-1))/2;
  cout << ans << endl;
      
}

Measured memory_bytes: 5216
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;


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

    vector<int> V(N), C(N), D(N);
    for (int n = 0; n < N; n++) cin >> V[n];
    for (int n = 0; n < N; n++) cin >> C[n];
    for (int n = 0; n < N; n++) D[n] = V[n] - C[n];

    sort(D.begin(), D.end(), greater<int>());

    int res = 0;
    for (int n = 0; n < N; n++) {
        if (D[n] > 0) res += D[n];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <numeric>
#include <iterator>
#include <array>
#include <utility>

using namespace std;
typedef long long ll;


#define FF first
#define SS second
#define ALL(c) begin((c)), end((c))
#define REP(i,n) for(ll i=0;i<(ll)n;++i)
inline int getInt() { int s; scanf("%d", &s); return s; }
/*
#define SIZE 500000
vector<ll> table(SIZE);



void sieve_of_eratosthenes() {
	iota(ALL(table), 0);
	for (int i = 2; i < SIZE; ++i)
		table[i] = i;
	for (int i = 2; i*i < SIZE; ++i)
	if (table[i])
	for (int j = i*i; j < SIZE; j += i)
		table[j] = 0;
}*/

typedef array<array<int, 10>, 10> Table;

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

void dd(Table &state, int from, int to) {
	if (from==to) return;
	vector<pair<int,int>> stack;
	stack.emplace_back(1,1);
	while (!stack.empty()) {
		auto p = stack.back();
		stack.pop_back();
		int x = p.FF;
		int y = p.SS;

		REP(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (state[ny][nx] == from) {
				stack.emplace_back(nx,ny);
				state[ny][nx] = to;
			}
		}
	}
}


int g_c;

int cc(Table & state) {
	vector<pair<int, int>> stack;
	stack.emplace_back(1, 1);
	int cnt = 0;
	while (!stack.empty()) {
		auto p = stack.back();
		stack.pop_back();
		int x = p.FF;
		int y = p.SS;

		REP(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (state[ny][nx] == g_c) {
				stack.emplace_back(nx, ny);
				cnt++;
				state[ny][nx] = -1;
			}
		}
	}
	return cnt;
}

int walk(int depth, Table state) {
	if (depth == 5) {
		Table ntable = state;
		ntable[1][1] = g_c;
		dd(ntable, state[1][1], g_c);
		return cc(ntable);
	}
	int cnt = 1;
	REP(i, 6) {
		Table ntable = state;
		ntable[1][1] = i;
		dd(ntable, state[1][1], i); //色変
		cnt = max(walk(depth+1, ntable),cnt);
	}
	return cnt;
}


int main() {

	while (true) {
		ll h,w;
		cin >> h >> w >> g_c;
		if (h == 0) break;
		g_c--;
		Table table;
		REP(y, 10) REP(x, 10) table[y][x] = -1;
		REP(y, h) REP(x, w) {
			cin >> table[y + 1][x + 1];
			table[y + 1][x + 1]--;
		}

		cout << walk(1, table) << endl;
	}
}

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

int main() {
  long n,k;
  cin >> n >> k;
  n = n % k;
  if(n == 0) {
    cout << n << endl;
  }
  else if(n > (n - k) * -1) {
    cout << (n - k) * -1 << endl;
  }
  else {
    cout << n << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
plus = []
minus = []
for i in range(n):
    s = input()
    mini = 0
    ruikei = 0
    for j in range(len(s)):
        if s[j] == '(':
            ruikei += 1
        else:
            ruikei -= 1
            mini = min(mini, ruikei)
    if ruikei > 0:
        plus.append([mini, ruikei])
    else:
        mini = 0
        ruikei = 0
        for j in range(len(s))[::-1]:
            if s[j] == ')':
                ruikei += 1
            else:
                ruikei -= 1
                mini = min(mini, ruikei)
        minus.append([mini, ruikei])

plus.sort(reverse=True, key=lambda x: x[0])
minus.sort(reverse=True, key=lambda x: x[0])

ans = 'Yes'
top_plus = 0
for i in range(len(plus)):
    mini, ruikei = plus[i]
    if top_plus + mini < 0:
        ans = 'No'
        break
    else:
        top_plus += ruikei

top_minus = 0
for i in range(len(minus)):
    mini, ruikei = minus[i]
    if top_minus + mini < 0:
        ans = 'No'
        break
    else:
        top_minus += ruikei

if top_plus != top_minus:
    ans = 'No'

print(ans)

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

sumList = [0] * n
sumList[0] = a[0] % m
number = {}
number[sumList[0]] = 0

for i in range(1, n):
    sumList[i] = (sumList[i - 1] + a[i]) % m
    number[sumList[i]] = 0

for i in range(n):
    number[sumList[i]] += 1

ans = 0

for key, value in number.items():
    ans += value * (value - 1) // 2
    if key == 0:
        ans += value

print(ans)


Measured memory_bytes: 14756
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int H, W, K;
char c[10][10];

int main() {
  cin >> H >> W >> K;

  int all_black = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> c[i][j];
      if (c[i][j] == '#')
        all_black++;
    }
  }

  int h[10];
  int w[10];
  for (int i = 0; i < H; i++) {
    h[i] = 0;
    for (int j = 0; j < W; j++)
      h[i] += c[i][j] == '#' ? 1 : 0;
  }
  for (int i = 0; i < W; i++) {
    w[i] = 0;
    for (int j = 0; j < W; j++)
      w[i] += c[j][i] == '#' ? 1 : 0;
  }

  // 全探索
  int res = 0;
  for (int i = 0; i < (1 << H); i++) {
    for (int j = 0; j < (1 << W); j++) {
      int sum = 0;
      for (int k = 0; k < H; k++)
        if (i & (1 << k))
          sum += h[k];
      for (int l = 0; l < W; l++)
        if (j & (1 << l))
          sum += w[l];

      for (int k = 0; k < H; k++) {
        for (int l = 0; l < W; l++) {
          if ((i & (1 << k)) && (j & (1 << l))) {
            sum -= (c[k][l] == '#' ? 1 : 0);
          }
        }
      }
      if ((all_black - sum) == K)
        res++;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
  ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
/*ll t;cin>>t;
 while(t--)
  {*/
    ll i, s=0,n;
  cin>>n;
   for(i=0;i<=n;i++)
    {
      if(i%3!=0 && i%5!=0 && i%15!=0)
     s+=i;
      }
     
      cout<<s;
     
}    

Measured memory_bytes: 3564
#include <iostream>
#include <map>

int main() {
  std::map<std::string, int> dict;

  long n;
  std::cin >> n;
  for (int i=0; i<n; i++) {
    std::string s;
    std::cin >> s;
    if (dict.find(s) == dict.end()) {
      dict.insert(std::make_pair(s, 1));
    } else {
      dict[s] += 1;
    }
  }

  std::cin >> n;
  for (int i=0; i<n; i++) {
    std::string s;
    std::cin >> s;
    if (dict.find(s) == dict.end()) {
      dict.insert(std::make_pair(s, -1));
    } else {
      dict[s] -= 1;
    }
  }

  int ans=0;

  for (auto const& p : dict) {
    if (p.second > ans)
      ans = p.second;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

int main(){
  string S;
  cin >> S;
  if(S=="ABC") cout << "ARC" << endl;
  if(S=="ARC") cout << "ABC" << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a % 2 && b % 2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256