akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long dp[3000][3000][2];
int main()
{
    long long n,sum=0;
    cin>>n;
    vector<long long> a(n);
    for(long long& x:a)
    {
        cin>>x;
        sum+=x;
    }

    for(long long i=0;i<n;i++)
    {
    dp[i][i][0]=a[i];
    dp[i][i][1]=0;
    }

    for(long long RminusL=1;RminusL<n;RminusL++)
    {
        for(long long L=0;L+RminusL<n;L++)
        {
            long long R=L+RminusL;
            dp[L][R][0]=max(a[L]+dp[L+1][R][1],a[R]+dp[L][R-1][1]);
            dp[L][R][1]=min(dp[L+1][R][0],dp[L][R-1][0]);
        }
    }
    long long x=dp[0][n-1][0];

    long long ans=2*x-sum;
    cout <<ans;
    return 0;
}

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

int main() {
  string S;
  ll K;
  cin >> S >> K;

  for (int i = 0; i < min((ll)S.size(),K); i++) {
    if (S[i] > '1') {
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;

  return 0;
}

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

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main() {
    int N, ans = 0;
    string S;
    string alpha = "abcdefghijklmnopqrstuvwxyz";
    cin >> N >> S;
    FOR(i, 1, N) {
        int count = 0;
        REP(j, alpha.size()) {
            if (S.substr(0, i).find(alpha[j]) != string::npos &&
                S.substr(i).find(alpha[j]) != string::npos)
                count++;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import copy
n=int(input())
a=list(map(int,input().split()))
b=copy.deepcopy(a)
for i in range(1,n):
  if a[i-1] > a[i]:
    a[i] = a[i-1]
print(sum([a[i]-b[i] for i in range(n)]))

Measured memory_bytes: 33316
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::{input, marker::{Isize1, Usize1, Bytes, Chars}};

//#[proconio::fastout]
fn main() {
    input!(
        n: i64,
        arr: [i64; 5],
    );
    let dr = arr.iter().min().unwrap();
    println!("{}", ((n + dr - 1) / dr) + 4);
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp2 {
	class Program {
		static void Main(string[] args) {
			var nm = Console.ReadLine().Split(' ').Select(ngo => int.Parse(ngo)).ToArray();
			var arr = Console.ReadLine().Split(' ').Select(ngo => int.Parse(ngo)).ToArray();

			var queue = new PriorityQueue<long>(nm[0], 1);
			for (int i = 0; i < arr.Length; ++i) queue.Push(arr[i]);

			for (int i = 0; i < nm[1]; ++i) {
				queue.Push(queue.Pop() / 2);
			}

			Console.WriteLine(queue.ToArray().Sum());
		}
	}


	public class PriorityQueue<T> where T : IComparable {
		private IComparer<T> _comparer = null;
		private int _type = 0;

		private T[] _heap;
		private int _sz = 0;

		private int _count = 0;

		/// <summary>
		/// Priority Queue with custom comparer
		/// </summary>
		public PriorityQueue(int maxSize, IComparer<T> comparer) {
			_heap = new T[maxSize];
			_comparer = comparer;
		}

		/// <summary>
		/// Priority queue
		/// </summary>
		/// <param name="maxSize">max size</param>
		/// <param name="type">0: asc, 1:desc</param>
		public PriorityQueue(int maxSize, int type = 0) {
			_heap = new T[maxSize];
			_type = type;
		}

		private int Compare(T x, T y) {
			if (_comparer != null) return _comparer.Compare(x, y);
			return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
		}

		public void Push(T x) {
			_count++;

			//node number
			var i = _sz++;

			while (i > 0) {
				//parent node number
				var p = (i - 1) / 2;

				if (Compare(_heap[p], x) <= 0) break;

				_heap[i] = _heap[p];
				i = p;
			}

			_heap[i] = x;
		}

		public T Pop() {
			_count--;

			T ret = _heap[0];
			T x = _heap[--_sz];

			int i = 0;
			while (i * 2 + 1 < _sz) {
				//children
				int a = i * 2 + 1;
				int b = i * 2 + 2;

				if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b;

				if (Compare(_heap[a], x) >= 0) break;

				_heap[i] = _heap[a];
				i = a;
			}

			_heap[i] = x;

			return ret;
		}

		public int Count() {
			return _count;
		}

		public T Peek() {
			return _heap[0];
		}

		public bool Contains(T x) {
			for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true;
			return false;
		}

		public void Clear() {
			while (this.Count() > 0) this.Pop();
		}

		public IEnumerator<T> GetEnumerator() {
			var ret = new List<T>();

			while (this.Count() > 0) {
				ret.Add(this.Pop());
			}

			foreach (var r in ret) {
				this.Push(r);
				yield return r;
			}
		}

		public T[] ToArray() {
			T[] array = new T[_sz];
			int i = 0;

			foreach (var r in this) {
				array[i++] = r;
			}

			return array;
		}
	}
}


Measured memory_bytes: 34524
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
	int n, m;
	int i, j;
	long long int a[100][100], b[100];
	long long int ans;

	cin >> n >> m;

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			a[i][j] = 0;
			b[j] = 0;
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (i = 0; i < n; i++) {
	    ans=0;
		for (j = 0; j < m; j++) {
			ans += a[i][j]*b[j];
		}
		cout << ans << endl;
	}

    return 0;
}




Measured memory_bytes: 3160
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;
 
LL N,M;
vector<int> G[100000];
int dist[100000];
int isOddCycle=0;
 
int dfs(int v,int p,int d){
    if(dist[v]==-1){
        dist[v]=d;
        REP(i,SZ(G[v])){
            if(G[v][i]!=p){
                dfs(G[v][i],v,d+1);
            }
        }
    }
}
 
int main(void){
    cin>>N>>M;
    REP(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    fill(dist,dist+100000,-1);
    dfs(0,-1,0);
    REP(i,N)
        REP(j,SZ(G[i]))
            if((dist[i]-dist[G[i][j]])%2==0)
                isOddCycle=1;
    if(isOddCycle){
        cout<<N*(N-1)/2-M<<endl;
    }else{
        LL nOddNode=0,nEvenNode=0;
        REP(i,N){
            if(dist[i]%2==0)
                nOddNode++;
            else
                nEvenNode++;
        }
        
        cout<<nOddNode*nEvenNode-M<<endl;
    }
     return 0;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
#define MOD 1000000007
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}
int const N = 1e5 + 2;

int main(){
	sync
	ll n, m;
	cin>>n>>m;
	vector< vector<ll> > vec(n, vector<ll> (m, 0));
	FOR0(i, n){
		FOR0(j, m){
			char x; cin>>x;
			if(x == '#')
				vec[i][j] = -1;
		}
	}
	vec[0][0] = !vec[0][0] ? 1 : 0;
	FOR1(i, n-1)
		vec[i][0] = vec[i][0] != -1 ? vec[i-1][0] : 0;
	FOR1(i, m-1)
		vec[0][i] = vec[0][i] != -1 ? vec[0][i-1] : 0;

	FOR1(i, n-1){
		FOR1(j, m-1){
			vec[i][j] = vec[i][j] != -1 ? (vec[i-1][j] % MOD + vec[i][j-1] % MOD) % MOD : 0;
		}
	}
	cout<<vec[n-1][m-1] % MOD<<"\n";
	return 0;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N;
ll A[100001];
ll B[100001];

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

  cin >> N;
  rep(i, N) cin >> A[i];
  ll sm = abs(A[0]);
  rep(i, N-1){
    sm += abs(A[i+1] - A[i]);
  }
  sm += abs(A[N-1]);

  rep(i, N){
    if (i==0) {
      if (A[0] > 0 && A[1] < A[0]) B[0] = A[0] - max(A[1], 0ll);
      else if (A[0] < 0 && A[1] > A[0]) B[0] = abs(A[0] - min(A[1], 0ll));
      else B[0] = 0;
      continue;
    }
    if (i==N) {
      if (A[N-1] > 0 && A[N-2] < A[0]) B[0] = A[N-1] - max(A[N-2], 0ll);
      else if (A[N-1] < 0 && A[N-2] > A[0]) B[0] = abs(A[N-1] - min(A[N-2], 0ll)); 
      else B[0] = 0;
      continue;
    }
    
    if (A[i] > A[i-1] && A[i] > A[i+1]) B[i] = abs(A[i] - max(A[i-1],A[i+1]));
    else if (A[i] < A[i-1] && A[i] < A[i+1]) B[i] = abs(A[i] - min(A[i-1],A[i+1]));
    else B[i] = 0;
  }

  rep(i, N){
    cout << sm - 2 * B[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007LL;
constexpr int MAX = 3000;
ll dp[MAX + 1][2];
ll dp2[MAX + 1][2];
int main()
{
    int N, M;
    cin >> N >> M;
    if (N == 1) {
        ll ans = 2;
        for (int i = 0; i < M; i++, (ans *= 2) %= MOD) {}
        return (cout << ans << endl), 0;
    }
    dp[0][1] = 1;
    for (int i = 1; i <= N; i++) { dp[i][0] = 1; }
    for (ll i = 0; i < M; i++) {
        dp2[0][1] = (dp[0][1] + dp[1][0] + dp[1][1]) % MOD;
        dp2[N][0] = (dp[N - 1][0] + dp[N][0]) % MOD, dp2[N][1] = (dp[N - 1][1] + dp[N][1]) % MOD;
        dp2[1][0] = (dp[1][0] + dp[2][0]) % MOD, dp2[1][1] = (dp[0][1] + dp[1][0] + 2 * dp[1][1] % MOD + dp[2][1]);
        for (int j = 2; j < N; j++) { dp2[j][0] = (dp[j - 1][0] + 2 * dp[j][0] % MOD + dp[j + 1][0]) % MOD, dp2[j][1] = (dp[j - 1][1] + 2 * dp[j][1] % MOD + dp[j + 1][1]) % MOD; }
        swap(dp, dp2);
    }
    ll ans = 0;
    for (ll i = 0; i <= N; i++) { (ans += dp[i][1]) %= MOD; }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;
int main()
{
	int n,a[110],cost[210]= {0};
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<=200; i++){
		for(int j=0; j<n; j++){
			cost[i] += (a[j] - (i - 100)) * (a[j] - (i - 100));
		}
	}
	int ans = 2e8;
	for(int i=0; i<=200; i++){
		ans = min(ans,cost[i]);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var s=input.trim();
for(var i=0;i<s.length-7;i++){
   var arr=[s[i],s[i+1],s[i+2],s[i+3],s[i+4],s[i+5],s[i+6],s[i+7]]; 
   if(arr.join("")=="AIZUNYAN"){
      i+=7;
      continue;
   }  
   var str=arr.sort().join("");
   if(str=="AADINNUY"){
      s=s.slice(0,i)+"AIZUNYAN"+s.slice(i+8,s.length);
      i+=7;
   }
}
console.log(s);

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

int main(){
  int N,R,S;//Sは内部レーティング//
  cin >> N >> R;
  if(N>=10){
    S=R;
  }
  else{
    S=R+100*(10-N);
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vs a(9);

int main(){
	a[0]=".,!? ";
	a[1]="abc";
	a[2]="def";
	a[3]="ghi";
	a[4]="jkl";
	a[5]="mno";
	a[6]="pqrs";
	a[7]="tuv";
	a[8]="wxyz";
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			int id=-1,cnt=0;
			for(auto c:s){
				if(c=='0'){
					if(id>=0){
						cout<<a[id][(cnt-1)%a[id].size()];
						id=-1;
						cnt=0;
					}
				}
				else{
					id=c-'1';
					cnt++;
				}
			}
			cout<<endl;
		}
		break;
	}
}


Measured memory_bytes: 3120
#include<cstdio>
#include<algorithm>

int tt[150000];

int main(void) {
    int n,c,k;
    scanf("%d%d%d",&n,&c,&k);

    int a=0, r=0, p=0;
    for(int i=0; i<n; i++)
        scanf("%d", &tt[i]);
    std::sort(tt, tt+n);

    for(int i=0; i<n; i++) {
        int t = tt[i];
        if(t > a || p >= c) {
            a = t + k;
            p = 1;
            r++;
        } else
            p++;
    }
    printf("%d\n", r);
}


Measured memory_bytes: 512
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    H, W = map(int, readline().split())
    C = [list(map(int, readline().split())) for _ in range(10)]
    A = list(map(int, read().split()))

    for k in range(10):
        for i in range(10):
            for j in range(10):
                if C[i][j] > C[i][k] + C[k][j]:
                    C[i][j] = C[i][k] + C[k][j]

    ans = 0
    for n in A:
        if n != -1:
            ans += C[n][1]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 42864
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
class Range {
    using T = long long;
    class Iterator {
        T val, step, diff;
    public:
        Iterator(T v, T s, T d): val(v), step(s), diff(d) {}
        T operator*() { return val + diff; }
        bool operator!=(const Iterator &itr) { return step > 0 ? val < itr.val : val > itr.val; }
        Iterator operator++() { val += step; return *this; }
    };
    Iterator _begin, _end;
public:
    Range(T b, T e, T s, T d): _begin(b, s, d), _end(e, s, d) {
        if (s < 0) { _begin = Iterator(e - 1, s, d); _end = Iterator(b - 1, s, d); }
    }
    Range(T b, T e, T s): Range(b, e, s, 0) {}
    Range(T b, T e): Range(b, e, 1, 0) {}
    Range(T e): Range(0, e, 1, 0) {}
    Iterator begin() { return _begin; }
    Iterator end() { return _end; }
};
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char c;
    cin, c;
    cout << char(c + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

const char gKeys[10][6] 
= {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};


int main(){
  char buf[1025];
  int N;
  while(~scanf("%d",&N)){
    for(int t=0;t<N;t++){
      scanf("%s",buf);
      queue<int> que;
      for(int i=0;i<strlen(buf);i++){
	if(buf[i] != '0') que.push(buf[i]-'0');
	else if(buf[i] == '0'){
	  if(que.empty()) continue;
	  int idx = que.size()-1;
	  int key = que.front();
	  int pos = idx%strlen(gKeys[key]);
	  printf("%c",gKeys[key][pos]);
	  que = queue<int>(); //clear que
	}
      }
      printf("\n");
    }
  }
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    vector<ll> lucas(n+1);
    lucas[0] = (ll) 2; lucas[1] = (ll) 1;
    for (int i = 2; i <= n; i++)
    {
        lucas[i] = lucas[i-1] + lucas[i-2];
    }
    cout << lucas[n] << endl;
    return 0;
}

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

int main(){

    ll x;
    cin >> x;

    ll ans=x/11;
    ans*=2;

    if(x%11!=0){
        if(x%11<=6){
            ans++;
        }else{
            ans+=2;
        }
    }

    cout << ans << endl;

    return 0;
}

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


using namespace std;

long long a[3009], dp[3009][3009];
int main() {
        int n;
        scanf("%d", &n);
        for (int i = 1; i <= n; i++) scanf("%lld", a + i);
        for (int left = n; left >= 1; left--) {
                for (int right = left; right <= n; right++) {
                        //[left, right]
                        bool taro = (left - 1 + n - right) % 2 == 0;
                        if (taro) {
                                if (left == right) {
                                        dp[left][right] = a[left];
                                } else {
                                        dp[left][right] = max(dp[left + 1][right] + a[left], dp[left][right - 1] + a[right]);
                                }
                        } else {
                                if (left == right) {
                                        dp[left][right] = -a[left];
                                } else {
                                        dp[left][right] = min(dp[left + 1][right] - a[left], dp[left][right - 1] - a[right]);
                                }
                        }
                }
        }
        printf("%lld", dp[1][n]);
}

Measured memory_bytes: 49956
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> plus = nextIntArray();
      ArrayList<Integer> minus = nextIntArray();
      int output = 0;
      for(int i = 0; i < N; i++){
        if(plus.get(i) > minus.get(i)){
          output += plus.get(i) - minus.get(i);
        }
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32976
#include<iostream>
#include<cstdio>
	using namespace std;
	const long long k=1e9;
int main()
{
	long long S=0;
	scanf("%lld",&S);
	long long x1=0,y1=0;
	long long x2=1,y2=k;
	long long x3=S/k+(S%k!=0),y3=x3*k-S;
	printf("%lld %lld %lld %lld %lld %lld",x1,y1,x2,y2,x3,y3);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main(void) {

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

	if (a + b > c + d) {
		cout << "Left" << endl;
	}

	else if (a + b < c + d) {
		cout << "Right" << endl;
	}

	else if (a + b == c + d) {
		cout << "Balanced" << endl;
	}




}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

vll get_factor(ll n){  
	vll ret;  
    while (n % 2 == 0)  
    {  
        ret.pb(2);  
        n = n/2;  
    }    
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {    
        while (n % i == 0)  
        {  
            ret.pb(i);  
            n = n/i;  
        }  
    }    
    if (n > 2)  
        ret.pb(n);
    return ret;  
}  

int solve(){
	ll n, ans = 0;
	cin>> n;
	vll factors = get_factor(n);
	sort(all(factors));
	rep(i, 0, (int)factors.size()){
		int j = i;
		ll cnt = 0;
		while(factors[j] == factors[i]){
			cnt++;
			j++;
			if(j == (int)factors.size())
				break;
		}
		i = j - 1;
		ll add = 1;
		while(true){
			if(add * (add + 1) / 2  >  cnt)
				break;
			add++;
		}
		add--;
		ans += add;
	}
	cout<< ans<< "\n";
	return 0;	
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    cout<<n*(n-1)/2;
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e20;
const int INF = 1e9;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int p, q, r;
  cin >> p >> q >> r;
  int ans = p + q + r;
  ans = ans - max(p, max(q, r));
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = a; i <= b; i++) {
        if(i < a+k or b-k < i) cout << i << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  int a, b ;
  cin >> a >> b ;
  if(a+b==15){
    cout <<"+"<<endl ;
  }
  else if (a*b==15){
    cout <<"*"<<endl ;
  }
  else{
    cout <<"x"<<endl ;
  }


  return 0 ;
}




Measured memory_bytes: 256
from fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
g=gcd(n,m)
ans=n*m//g
stepn=n//g
stepm=m//g
for i in range(g):
    if s[stepn*i]!=t[stepm*i]:print(-1);exit()
print(ans)

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

int main(void) {

	string S;
	cin >> S;

	int total = 700;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') {
			total += 100;
		}
	}

	cout << total << endl;

	return 0;
}



Measured memory_bytes: 256
function main(input) {
    const args = input.split('\n');
    const A = parseInt(args[0], 10),
          B = parseInt(args[1], 10),
          C = parseInt(args[2], 10),
          X = parseInt(args[3], 10);

    var count = 0;

    for (var a = 0; a <= A; ++a) {
        for (var b = 0; b <= B; ++b) {
            for (var c = 0; c <= C; ++c) {
                var sum = (a * 500) + (b * 100) + (c * 50);
                if (sum === X) ++count;
            }
        }
    }
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
 
using namespace std;
const int N=2e5+1, mod=998244353;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	string s;
	cin>>s;
	if(s=="SUN")cout<<"7";
	else if(s=="MON") cout<<"6";
	else if(s=="TUE") cout<<"5";
	else if(s=="WED") cout<<"4";
	else if(s=="THU") cout<<"3";
	else if(s=="FRI") cout<<"2";
	else if(s=="SAT") cout<<"1";
	
    yogeshk972();
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var min = Int.MAX_VALUE
    for (i in 1..(n-1)) {
        val temp = sumDigit(i) + sumDigit(n - i)
        min = Math.min(min,temp)
    }
    println(min)
}

fun sumDigit(num: Int): Int {
    val str = num.toString()
    var sum = 0
    str.forEach { sum += it.toString().toInt() }
    return sum
}

Measured memory_bytes: 48448
import java.util.*;
public class Main 
{
	static List<Integer> prime = new ArrayList<Integer>();
	static boolean[] isPrime = new boolean[1000000];
	static void primeCalc()
	{
		for(int i = 0; i < isPrime.length; ++i)
		{
			isPrime[i] = true;
		}
		isPrime[0] = isPrime[1] = false;
		for(int i = 2; i < isPrime.length; ++i)
		{
			if(isPrime[i])
			{
				prime.add(i);
				for(int j = 2 * i; j < isPrime.length; j += i)
				{
					isPrime[j] = false;
				}
			}
		}
	}
	public static void main(String[] args) 
	{
		primeCalc();
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int a = stdIn.nextInt();
			int d = stdIn.nextInt();
			int n = stdIn.nextInt();
			if(a == 0 && d == 0 && n == 0)
			{
				break;
			}
			int num = a;
			int ans = 0;
			int count = 0;
			while(count < n)
			{
				if(isPrime[num])
				{
					ans = num;
					++count;
				}
				num += d;
			}
			System.out.println(ans);
		}
	}
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int d[110][110];
int pre[110][110];

void warshall_floyd(int n){
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            pre[i][j] = i;
        }
    }

	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
                if(d[i][j] > d[i][k]+d[k][j]){
                    d[i][j]=d[i][k]+d[k][j];
                    pre[i][j]=pre[k][j];
                }
			}
		}
	}
}

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

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i == j) d[i][j]=0;
            else d[i][j]=MOD;
        }
    }

    for(int i=0; i<m; i++){
        int a, b, c; cin>>a>>b>>c;
        a--, b--;
        d[a][b]=c;
        d[b][a]=c;
    }

    bool visited[110][110];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(d[i][j] == 0 || d[i][j] == MOD) visited[i][j]=true;
            else visited[i][j]=false;
            //cout << d[i][j] << " ";
        }
        //cout << endl;
    }

    warshall_floyd(n);

    for(int s=0; s<n; s++){
        for(int g=0; g<n; g++){
            if(s == g) continue;

            int save[110];
            int i=0;
            for(int cur=g; cur!=s; cur=pre[s][cur]){
                save[i]=cur;
                i++;
                //cout << cur << " ";
            }
            //cout << s << endl;
            save[i]=s;

            for(int j=0; j<i; j++){
                visited[save[j]][save[j+1]]=true;
                visited[save[j+1]][save[j]]=true;
            }
        }
    }

    int cnt=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(!visited[i][j]) cnt++;
        }
    }
    cout << cnt / 2 << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int h,w;
	char c[1111][1111];
	ll dp[1111][1111];
	cin>>h>>w;
	REP(i,h)
		REP(j,w)
		{
			cin>>c[i][j];
			dp[i][j]=0;
		}
	bool flag=0;
	REP(i,w)
	{
		if(c[0][i]=='#')flag=1;
		if(!flag)dp[0][i]=1;
	}
	flag=0;
	REP(i,h)
	{
		if(c[i][0]=='#')flag=1;
		if(!flag)dp[i][0]=1;
	}
	for(int i=1;i<h;i++)
		for(int j=1;j<w;j++)
		{
			if(c[i][j]!='#')dp[i][j]=dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=mod;
		}
//	REP(i,h)
//	{
//		REP(j,w)
//			cout<<dp[i][j]<<" ";
//		cout<<endl;
//	}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}



Measured memory_bytes: 11008
#include <stdio.h>
int main(void)
{
    int N,i,j,k,A[101],v;
    
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&A[i]);
        if(i==N-1) printf("%d\n",A[i]);
        else printf("%d ",A[i]);
    }
    
    for(i=1;i<=N-1;i++)
    {
        v=A[i];
        j=i-1;
        while(j>=0 && A[j]>v)
        {
            A[j+1]=A[j];
            j--;
            A[j+1]=v;
        }
        for(k=0;k<N;k++)
        {
            if(k==N-1) printf("%d\n",A[k]);
            else printf("%d ",A[k]);
        }
    }
    
    
    return 0;
}




Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int f=0;
    for(int i=0;i*4<=n;++i)
    {
        if((n-4*i)%7==0)
            f=1;
    }
    if(f)
        cout<<"Yes";
    else
        cout<<"No";
}

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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int X,  A; cin>>X>>A;
  cout << (X < A ? 0 : 10) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void){
  ll n,s=0;
  cin >> n;
  rep(i,n){
    if(i>0)s=s+(n-1)/i;
  }
  cout << s;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;
ll n,d;
ll a1[N],a2[N];
int main()
{  fast
cin>>n>>d;
d=d*d;
for(int i=1;i<=n;i++){
	cin>>a1[i]>>a2[i];
}
int ans=0;
for(int i=1;i<=n;i++) {
	ll x=a1[i]*a1[i]+a2[i]*a2[i];
	if(x<=d)
	ans++;
}
cout<<ans;
}

Measured memory_bytes: 6764
#include <iostream>
#include <vector>
#include <algorithm>
 
using V = std::vector<uint64_t>;
 
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
 
  int N;
  std::cin >> N;
 
  V a(N, 0), b(N, 0), c(N, 0);
  for (int i = 0; i < N; i++) {
    std::cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    std::cin >> b[i];
  }
  for (int i = 0; i < N; i++) {
    std::cin >> c[i];
  }
  std::sort(a.begin(), a.end());
  std::sort(b.begin(), b.end());
  std::sort(c.begin(), c.end());
 
  V bs(N);
  for (int i = 0; i < N; i++) {
    bs[i] = c.end() - std::upper_bound(c.begin(), c.end(), b[i]);
  }
 
  V sum(N);
  sum[N - 1] = bs[N - 1];
  for (int i = N - 2; i >= 0; i--) {
    sum[i] = sum[i + 1] + bs[i];
  }
 
  uint64_t ans = 0;
  for (int i = 0; i < N; i++) {
    ans += sum[std::upper_bound(b.begin(), b.end(), a[i]) - b.begin()];
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
const int nmax = 8;
bool gragh[nmax][nmax];

using namespace std;

int dfs(int v, int N, bool visited[nmax]) {

    bool all_visited = true;

    for(int i = 0; i < N; ++i) {
        // 訪れていないところがあれば
        if (visited[i] == false) all_visited = false;
    }

    if (all_visited) return 1;

    int ret = 0;

    // すべての可能性を上げる
    for(int i = 0; i < N; ++i) {
        // 辺がなければ
        if (gragh[v][i] == false) continue;
        // すでに訪れていれば
        if(visited[i] == true) continue;

        visited[i] = true;
        ret += dfs(i, N, visited);

        // 次のループのためにフラグを折る
        visited[i] = false;
    }

    return ret;
}

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

    // 隣接行列を作る　
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        gragh[a-1][b-1] = gragh[b-1][a-1] = true;
    }

    bool visited[nmax];
    for(int i = 0; i < N; ++i) {
        visited[i] = false;
    }
    // 1が始点
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
    return 0;
}

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

int N;

int as[100005];
int dp[100005];

int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&as[i]);
  }
  dp[0]=0;
  for(int i=1;i<N;i++){
    dp[i]=dp[i-1]+std::abs(as[i]-as[i-1]);
    if(i>1){
      dp[i]=std::min(dp[i],dp[i-2]+std::abs(as[i]-as[i-2]));
    }
  }
  printf("%d\n",dp[N-1]);
  return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int ma = 1000000000;

int N, K;

int binary_tree(vector<int> A, int left, int right){
    if(left+1 == right) return right;
    int mid = (left + right) / 2;



    int cnt = 0;
    rep(i,N){
        if(A[i] % mid == 0){
            cnt += A[i] / mid - 1;
        }else{
            cnt += A[i] / mid;
        }
    }
    if(cnt > K) return binary_tree(A, mid, right);
    // else if(cnt == K) return mid;
    else return binary_tree(A, left, mid);
}

int main()
{
    cin >> N >> K;
    vector<int> A;
    
    rep(i,N){
        int Ai; cin >> Ai;
        A.push_back(Ai);
    }
    sort(A.begin(), A.end());
    cout << binary_tree(A, 0, ma) << endl;
}

Measured memory_bytes: 28420
#include<stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(W<(x+r)||H<(y+r)){
            printf("No\n");
        }else if((x-r)<0||(y-r)<0)
        {
            printf("No\n");
        }
        else{ printf("Yes\n");}
        return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){

  /*while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }else{
      u = u->right;
    }
  }
  return u;*/

  while(u != NIL){
    if(u->key == k){
      return u;
    }else if(u->key > k){
      u = u->left;
    }else{
      u = u->right;
    }
  }
    return NIL;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;



  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
    
    z->parent = y;
    

    if(y == NIL){
      root = z;
    }else if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
    




}

void inorder(Node u){

  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){

  if(u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
   if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
  }

  }
  return 0;
}




Measured memory_bytes: 25180
#include <iostream>

using namespace std;

int main(){
    int y;
    int x;
    int z;
    float x1;

    cin >> x; 
    x1 = x/1000.0;
    z = (x + (1000-1))/1000;

    // z = x - 1000 * y;
    y = 1000 * z - x;
    cout << y << endl;
    
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>

int main(){
    int a, b, i, d;
  
  while(1){
      scanf("%d %d", &a, &b);
      if(a == 0 && b == 0) break;
      
      for(i = 0; i < a; i++){
          for(d = 0; d < b; d++){ 
              printf("#");
      }
      printf("\n");
  }
  printf("\n");
}
return 0;
}


Measured memory_bytes: 2036
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

dist_sum = 0
for n, i in enumerate(XY[:-1]):
    for j in XY[n+1:]:
        dist_sum += ((i[0] - j[0])**2 + (i[1] - j[1])**2) ** 0.5
print(dist_sum * 2 / N)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=1234567890123;
#define ff(i,n) for(i=0;i<n;i++)
#define gg1(n1) cin>>n1;
#define gg(n1,n2) cin>>n1>>n2;
#define gg3(n1,n2,n3) cin>>n1>>n2>>n3;
#define hh(n) cout<<n<<endl;
#define t top
#define p push
#define pb push_back
#define mp make_pair
int main()
{
  ll i,n,k,j;
  cin>>n;
  ll a[n],b[n],c[n];
  for(i=0;i<n;i++)
     cin>>a[i]>>b[i]>>c[i];
  ll dpa[n],dpb[n],dpc[n];
  dpa[0]=max(b[0],c[0]);
  dpb[0]=max(a[0],c[0]);
  dpc[0]=max(b[0],a[0]);
  for(i=1;i<n;i++)
  {
       dpa[i]=a[i]+max(dpb[i-1],dpc[i-1]);
       dpb[i]=b[i]+max(dpa[i-1],dpc[i-1]);
       dpc[i]=c[i]+max(dpa[i-1],dpb[i-1]);
  }
  cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]));
  return 0;
}

Measured memory_bytes: 4992
import java.util.*;
import java.io.*;

class Main
{
	public static void main( String[] args )
	{
		Main m = new Main();
		m.A();
	}

	void A()
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		if(n == 1) System.out.println("Hello World");
		if(n == 2)
		{
			int a = in.nextInt(), b = in.nextInt();
			System.out.println(a + b);
		}
	}

	// int numWays(int k)
	// {
	// 	if(k < 3) return 1;
		
	// }


	// static int B(String str)
	// {
	// 	int cur = Integer.valueOf(str);
	// 	for(int i = 111; i <= 999; i += 111)
	// 		if(cur <= i) return i;
	// 	return cur;	// should not execute this line
	// }

	// static String update(String str)
	// {
	// 	char[] ch = str.toCharArray();
	// 	for(int i = 0; i < 3; i++)
	// 	{
	// 		if(ch[i] == '1') ch[i] = '9';
	// 		else ch[i] = '1';
	// 	}
	// 	return String.valueOf(ch);
	// }

}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){
    int A,B,K=-1,S;

    scanf("%d%d",&A,&B);
    S=A+B;
    if(S%2==0){
        K=S/2;
    }
    if(K==-1){
        printf("IMPOSSIBLE\n");
    }else{
        printf("%d\n",K);
    }
}

Measured memory_bytes: 128