akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int[] histgram = new int[26];
        for (int i = 0; i < H; i++) {
            String s = scan.next();
            char[] list = s.toCharArray();
            for (int j = 0; j < W; j++) {
                histgram[list[j]-'a'] += 1;
            }
        }
        int count_quad = 0;
        int count_not_quad = 0;
        int[] count = new int[4];
        for (int i = 0; i < 26; i++) {
            count[histgram[i] % 4] += 1;
        }
        if (H % 2 == 0 && W % 2 == 0) {
            if (count[1] == 0 && count[2] == 0 && count[3] == 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            return;
        }
        if (H % 2 == 1 && W % 2 == 0) {
            if (0 < count[1]) {
                System.out.println("No");
                return;
            }
            if (W / 2 < count[2]) {
                System.out.println("No");
                return;
            }
            if (0 < count[3]) {
                System.out.println("No");
                return;
            }
            System.out.println("Yes");
            return;
        }
        if (W % 2 == 1 && H % 2 == 0) {
            if (0 < count[1]) {
                System.out.println("No");
                return;
            }
            if (H / 2 < count[2]) {
                System.out.println("No");
                return;
            }
            if (0 < count[3]) {
                System.out.println("No");
                return;
            }
            System.out.println("Yes");
            return;
        }
        if (1 < count[1]) {
            System.out.println("No");
            return;
        }
        if (1 < count[3]) {
            System.out.println("No");
            return;
        }
        if (count[1] == 1 && count[3] == 1) {
            System.out.println("No");
            return;
        }
        if ((H - 1) / 2 + (W - 1) / 2 < count[2] + count[3]) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
        return;
    }
}


Measured memory_bytes: 23892
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;


 int main()
 {
   int n;
   while(cin>>n)
   {
     int kk=(24-n)+24;
     cout<<kk<<endl;             
   }
   return 0;
 }
 

        


Measured memory_bytes: 256
def resolve():
    s = input()
    ans = 0
    for i in range(2**(len(s)-1)):
        test = []
        cal = ""
        for j in range(len(s)-1):
            test.append((i>>j) & 1)
        for j in range(len(test)):
            if test[j] == 0:
                cal = cal + s[j]
            else:
                cal += s[j] + "+"
        cal += s[-1]
        ans += eval(cal)
    print(ans)
resolve()

Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define size 5005
const long MOD = 1e9+7;
pair<int,int>pos[size];
signed main()
{
    long test;
    test=1;
    // cin>>test;
    while(test--){
    long i,j,b,n,x,k,ans,most,index,c,maxi=0,temp,aw,bw,w,count,sum;
    cin>>n;
    ans=1;
    for(i=1;i<=n;i++)
    {
        ans=(ans*i)%MOD;
    }
    cout<<ans%MOD;
    }
}

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

#include <iostream>
#include <string>
using namespace std;

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

	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	for(int i=0; i<S.size(); i++){
		if(i == K-1){
			if(S[i] == 'A'){ S[i] = 'a'; }
			else if(S[i] == 'B'){ S[i] = 'b'; }
			else if(S[i] == 'C'){ S[i] = 'c'; }
		}
	}
	printf("%s\n", S.c_str());
	return 0;
}


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

A=max(a)

def min_factor(k):
    d=[]
    for i in range(k+1):
        d.append(i)

    i=2
    while i*i<=k:
        if d[i]==i:
            j=i*i
            while j<=k:
                if d[j]==j:
                    d[j]=i
                j+=i
        i+=1
    
    return d

def prime_factor_set(p):
    s=set()
    while p!=1:
        s.add(d[p])
        p//=d[p]  
    
    return s


d=min_factor(A)
cur=set()
flg=True
for i in range(n):
    tmp = prime_factor_set(a[i])
    if len(cur&tmp)>=1:
        flg=False
        break
    cur |= tmp

import numpy as np

g= np.gcd.reduce(a)

if flg:
    ans='pairwise coprime'
elif not flg and g==1:
    ans='setwise coprime'
else:
    ans='not coprime'

print(ans)

Measured memory_bytes: 127648
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    int i;
    int re=0,count=0;
    cin>>n;
    for(i=sqrt(n);i>0;i--){
        if(n%i==0) {
            re=n/i;
            break;
        }
    }
    for(;re>0;re/=10)
        count++;
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
n=format(int(input()),'032b')
n_li=list(n)
inversion_n=["1" if n_li[i]=="0"  else "0" for i in range(len(n_li))]
inversion_n= "".join(inversion_n)
left=n[1:len(n)]+"0"
right="0"+n[0:len(n)-1]
print(n)
print(inversion_n)
print(left)
print(right)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#include <numeric>
using namespace std;

long long A, B, C, D;

// long long gcd(long long a, long long b) {
//    if (a % b == 0) {
//        return b;
//    } else {
//        return gcd(b, a % b);
//    }
// }

long long lcm(long long a, long long b)
{
   // return a * b / gcd(a, b);
   return a / __gcd(a, b) * b;
}

int main() {
    cin >> A >> B >> C >> D;

    long long ans = B - A + 1LL;

    long long c = 0, d = 0, cd = 0;
    long long c_min, c_max, d_min, d_max, cd_min, cd_max;
    c_min = ceil((long double)A / C);
    c_max = B / C;
    d_min = ceil((long double)A / D);
    d_max = B / D;

    long long v = lcm(C, D);
    cd_min = ceil((long double)A / v);
    cd_max = B / v; 

    // printf("%lld %lld %lld %lld %lld %lld\n", c_min, c_max, d_min, d_max, cd_min, cd_max);
    c = c_max - c_min + 1LL;
    d = d_max - d_min + 1LL;
    cd = cd_max - cd_min + 1LL;
    // printf("c: %d d: %d cd: %d\n", c, d, cd);

    long long minus = c + d - cd;
    cout << ans - minus << endl;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

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

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"6
G W Y P Y W"# => r#"Four"#,

r#"9
G W W G P W P G G"# => r#"Three"#,

r#"8
P Y W G Y W Y Y"# => r#"Four"#,

}


fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        mut s: [String; n],
    }
    s.sort();
    s.dedup();

    // println!("{:?}", s);
    if s.len() == 4 {
        "Four"
    } else {
        "Three"
    }.to_string()
}

Measured memory_bytes: 4352
#include<iostream>
 
using namespace std;
 
int main() {
    int q,c[100], a[100], n[100];
    cin >> q;
    for (int i = 0; i < q; i++)cin >> c[i] >> a[i] >> n[i];
 
    for (int i = 0; i < q; i++) {
        int cnt = 0;
        if (c[i] != 0) {
            while (c[i] > 0 && a[i] > 0 && n[i] > 0) {
                c[i]--; a[i]--; n[i]--;
                cnt++;
            }
            while (c[i] > 1 && a[i] > 0) {
                c[i] -= 2; a[i]--;
                cnt++;
            }
            while (c[i] > 2) {
                c[i] -= 3;
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int h[105];
  int max = -1;
  int count = 0;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> h[i];
    if(max < h[i]) max = h[i];
  }
  h[n] = 0;
  for(int i=0; i<max; i++){
    for(int j=0; j<n; j++){
      if(h[j] != 0){
	count++;
	while(1){
	  h[j] -= 1;
	  if(h[j+1] == 0) break;

	  j++;
	}
      }
    }
  }
  cout << count << endl;
  return 0;
}


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

int main() {
  int X, Y;
  cin >> X >> Y;
  int b_2 = Y - 2 * X;
  int a_2 = 4 * X - Y;
  if (b_2 >= 0 && a_2 >= 0 && a_2 % 2 == 0 && b_2 % 2 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            String T = sc.next();
            int A = sc.nextInt();
            int B = sc.nextInt();
            String U = sc.next();

            if (S.equals(U)) {
                A--;
            } else {
                B--;
            }

            System.out.println(A + " " + B);
        }
    }

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 2e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-6;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
ll v[N];
void solve(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    ll ans = 0;
    ll mx = 0;
    for(int i = 0; i < n; i++){
        if(v[i] > mx){
            mx = v[i];
        }else{
            ans += abs(v[i] - mx);
        }
    }
    cout << ans << '\n';
}
int main(){
    FIN;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    //EjecuteTime;
    return 0;
}       


Measured memory_bytes: 5212
line = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())
print(line[K-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n, W;
    cin >> n >> W;
    vector<int> v(n), w(n);
    vector<vector<int> > dp(n+1, vector<int>(W+1, 0));
    rep(i,n)cin >> v[i] >> w[i];

    rep(i,n){
        //cout << "x";
        rep(j,W+1){
            //cout << "y";
            if(j >= w[i]){
                dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
                //cout << dp[i+1][j] << " ";
               // cout << w[i] << " " << dp[i][j - w[i]] + v[i] << " " << dp[i][j] << endl;
            }
            else dp[i+1][j] = dp[i][j];
        }
        //cout << "z";
    }
    cout << dp[n][W] << endl;
    
    /*rep(i,n+1){
        rep(j,W+1)cout << dp[i][j] << " ";
        cout << endl;
    }*/
    return 0;
}


Measured memory_bytes: 6764
#include<stdio.h>
#include<cctype>
using namespace std;
int main(){
    char ch;
    int A[26]={},num;
    while(scanf("%c",&ch)!=EOF){
        ch=tolower(ch);
        if(isalpha(ch)){
            num = ch-'a';
            A[num]+=1;
        }
    }
    for(int i = 0;i<26;i++){
        printf("%c : %d\n",i+'a',A[i]);
        
    }return 0;
}


Measured memory_bytes: 2704
#include<iostream>
using namespace std;
int main(){
	int x,y,z,k,s,num=0;
	cin>>k>>s;
     for(x=0;x<=k;x++){
     	for(y=0;y<=k;y++){
     	if((s-x-y)>=0&&(s-x-y)<=k)
     	num++;
		 }
	 }
	cout<<num;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
using std::swap;

//std::vector <pair<int, int>> LR;

int main()
{	
	int N, M,L,R;
	cin >> N >> M;
	L = 0;
	R = 1000000;
	//LR.resize(M);
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		if (L < a)L = a;
		if (R > b)R = b;
		//LR[0].first = a;
		//LR[0].second = b;
	}
	if (R - L + 1 <= 0)cout << 0 << "\n";
	else (R - L + 1) > N ? cout << N << "\n" : cout << R - L + 1 << "\n";
	return 0;
}

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

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

    vector<string> g(H);
    for(int i = 0; i < H; i++) cin >> g[i];

    vector<bool> row(H, false);
    vector<bool> col(W, false);

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(g[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }
    for(int i = 0; i < H; i++){
        if(row[i]){
            for(int j = 0; j < W; j++)
                if(col[j]) cout << g[i][j];

            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
using namespace std;
template<typename T>inline void read(T &x)
{
	T s=0,f=1;char k=getchar();
	while(!isdigit(k)&&(k^'-'))k=getchar();
	if(!isdigit(k)){f=-1;k=getchar();}
	while(isdigit(k)){s=s*10+(k^48);k=getchar();}
	x=s*f;
}
const int MAXN=110010;
int n;
long long a[MAXN],b[MAXN],c[MAXN];
unsigned long long dp[MAXN],ans;
void init()
{
	read(n);
	int i;
	For(i,1,n)read(a[i]);
	For(i,1,n)read(b[i]);
	For(i,1,n)read(c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
}
void solve()
{
	int i;
	For(i,1,n)dp[i]=dp[i-1]+(int)(lower_bound(a+1,a+n+1,b[i])-a)-1;
	For(i,1,n)ans+=dp[(int)(lower_bound(b+1,b+n+1,c[i])-b)-1];
	cout<<ans<<endl;
}
int main()
{
init();
solve();
return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	if(abs(a-b)%2==0){
		cout << abs(a-b)/2;
	}
	else{
		ll ans1=min(max(a,b)-1,n-min(a,b));
		ll ans2=((max(a,b)-min(a,b))-1)/2+min(a,b);
		ll ans3=(n-(n-max(a,b)+1+min(a,b)))/2+n+1-max(a,b);
	//	cout << ans1<<" "<<ans2<<" "<<ans3<<endl;
		cout << min({ans1,ans2,ans3});
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
N,T = map(int,input().split())
t = [int(x) for x in input().split()]
p=0
s=t[0]
for i in range(1,N):
  if t[i] - t[i-1] >= T:
    s += t[i]-t[i-1]-T
print(t[-1]+T-s)


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

int main () 
{
    int a, b, c;
    cin >> a >> b >> c;
    
    
    int i;
    for (i=0; a <= b; a++) {
        if (c % a == 0) {
            i++;
        }
    }
    
    cout << i << endl;

    return 0;
} 


Measured memory_bytes: 3104
N = int(input())
A = list(map(int, input().split()))

positive = 0
negative = 0

for a in A:
    if a > 0:
        positive += a
    else:
        negative += a

if positive == 0:  # 全部負
    # 一番大きい数から残りをすべて引く
    A.sort(reverse=True)
    now = A[0]
    ans = []
    for a in A[1:]:
        ans.append((now, a))
        now -= a
    print(now)
    for a in ans:
        print(*a)
elif negative == 0:  # 全部非負
    # 一番小さい数から引いて，最後に大きい数から引く
    A.sort()
    now = A[0]
    ans = []
    for a in A[1: N - 1]:
        ans.append((now, a))
        now -= a
    ans.append((A[-1], now))
    now = A[-1] - now
    print(now)
    for a in ans:
        print(*a)
else:
    A.sort()
    neg = A[0]
    pos = A[-1]
    ans = []
    for a in A[1: N - 1]:
        if a > 0:
            ans.append((neg, a))
            neg -= a
        else:
            ans.append((pos, a))
            pos -= a
    ans.append((pos, neg))
    print(pos - neg)
    for a in ans:
        print(*a)


Measured memory_bytes: 20152
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void) {
  int n, c = 0, flag = 1;
  char w[102][12], kari[2];

  if(scanf("%d", &n) != 0);

  for(int i = 0; i < n; i++) {
    if(scanf("%s", w[i]) != 0);
  }

  for(int i = 0; i < n - 1 && flag; i++) {
    for(int j = i + 1; j < n; j++) {
      if(strcmp(w[i], w[j]) == 0) {
        printf("No");
        flag = 0;
        break;
      }
    }
  }

  kari[0] = w[0][strlen(w[0]) - 1];

  for(int i = 1; i < n && flag; i++) {
    if(kari[0] == w[i][0]) {
      c++;
    } else {
      printf("No");
      break;
    }

    if(c == n - 1) {
      printf("Yes");
    }
    kari[0] = w[i][strlen(w[i]) - 1];
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
#ifdef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
  boost::for_each(vc, [&os](T value) {
#else
  std::for_each(vc.begin(), vc.end(), [&os](T value) {
#endif
    os << value << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;
  ui N{}; cin >> N;

  vector<map<char, ui>> v(N);

  ull ans{};
  rep(0, N) cin >> v[i]['V'];
  rep(0, N) cin >> v[i]['C'];

  boost::for_each(v, [&ans](auto m) {
    if (m['V'] > m['C']) ans += m['V'] - m['C'];
    });

  using std::cout;
  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector< int > P(N + 2);
  for(int i = 1; i <= N; i++) {
    cin >> P[i];
  }
  P[0] = 0, P[N + 1] = N + 1;

  vector< int > po(N + 2);
  for(int i = 0; i < P.size(); i++) po[P[i]] = i;

  vector< int64 > dp(N + 2, infll);
  dp[0] = 0;

  for(int i = 1; i <= N + 1; i++) {
    vector< int64 > dp2(N + 2, infll);
    int64 sm = infll;
    for(int j = 0; j <= N + 1; j++) {
      chmin(sm, dp[j]);
      if(po[i] == j) chmin(dp2[j], sm);
      else if(po[i] > j) chmin(dp2[j], sm + B);
      else chmin(dp2[j], sm + A);
    }
    dp.swap(dp2);
  }
  cout << dp[N + 1] << endl;
}




Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>


using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

int n;
long double x[9],y[9];
long double sum=0;
long double cnt = 0;


int main(){
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> x[i] >> y[i];
        v[i] = i+1;
    }
    for(int k=1;k<n;k++){
        int i = v[k-1]-1;
        int j = v[k]-1;
        long double dx = x[i] - x[j];
        long double dy = y[i] - y[j];
        sum += (long double)sqrt(dx*dx + dy*dy);
    }
    cnt +=1;
    while( next_permutation(v.begin(), v.end())){
        for (int k=1;k<n;k++){
            int i = v[k-1]-1;
            int j = v[k]-1;
            long double dx = x[i] - x[j];
            long double dy = y[i] - y[j];
            sum += (long double)sqrt(dx*dx + dy*dy);
        }
        cnt+=1;
        // cout << cnt << endl;
    }
    cout << fixed << setprecision(18) << (long double)sum/cnt << endl;
    return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m, ans = 0; cin >> n >> m;
    vi x(m);
    rep(i, m) cin >> x[i];
    if(n >= m) cout << 0 << endl;
    else{
        sort(all(x));
        vi rdis(m);
        rep(i, m){
            if(i == 0) rdis[i] = 0;
            else rdis[i] = x[i] - x[i-1];
        }
        sort(all(rdis), greater<int>());
        for(ll i=n-1; i<rdis.size(); i++) ans += rdis[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 2000000;

int main(){
    int R[MAX], n;
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i = 1; i < n; i++ ){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    string A,B,C;
    cin>>A>>B>>C;

    if(A[A.length()-1]==B[0]
    &&B[B.length()-1]==C[0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	printf("%d\n",(s!="SUN")?((s!="MON")?((s!="TUE")?((s!="WED")?((s!="THU")?((s!="FRI")?((s!="SAT")?-1:1):2):3):4):5):6):7);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,minv,gcd,sum=0;
  cin>>n;
  for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
	  for(int k=1; k<=n; k++){
	    minv=min(i,min(j,k));

	    for(int l=1; l<=minv; l++){
	      if(i%l==0 && j%l==0 && k%l==0)gcd=l;
	    }
	    sum+=gcd;
	  }
      }
  }
  cout<<sum<<'\n';
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main
{
	public static void main(String aeg[])
	{
		Scanner in = new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int s=0;
			for(int i=0; i<(n*(n-1))/2;i++)
				s+=in.nextInt();
			System.out.println(s/(n-1));
		}
	}
}

Measured memory_bytes: 13000
n = int(input())
trump = dict()

for i in range(n):
    mark, num = input().split()
    mark = str(mark)
    num =int(num)
    if mark not in trump:
        trump[mark] = list()
    trump[mark].append(num)

for mark in trump:
    if mark == 'S':
        for i in range(1,14):
            if i not in trump[mark]:
                print(mark, i)

for mark in trump:
    if mark == 'H':
        for i in range(1,14):
            if i not in trump[mark]:
                print(mark, i)

for mark in trump:
    if mark == 'C':
        for i in range(1,14):
            if i not in trump[mark]:
                print(mark, i)

for mark in trump:
    if mark == 'D':
        for i in range(1,14):
            if i not in trump[mark]:
                print(mark, i)



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

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

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

    int ans=0;

    for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)for(int k=0;k<=c;k++)
    {
        if(i*500+j*100+k*50==x)ans++;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18

using namespace std;






int main(){
	int n;
	cin >> n;
	vector<int> a;
	a.resize(n);
	for(int i=0; i<n; i++) cin >> a[i];
	
	sort(a.begin(), a.end(), greater<int>());
	int bob=0, alice=0;
	
	for(int i=0; i<n; i++){
		if(i%2==0){
			alice+=a[i];
		}
		else{
			bob += a[i];
		}
	}
	
	cout<<alice-bob<<endl;
	
	return 0;
}




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

int main(){
int a,b,c,k;
int sum=0;
cin >> a >> b >> c >> k;
for(int i=0; i < k;i++){
if(a > 0){
    sum += 1;
    a--;
}
else if(b > 0){
    b--;
}
else if(c > 0){
    sum += -1;
    c--;
}
}
cout << sum << endl;
}

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

signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    sort(v.begin(),v.end());
    
    
    vector<int> ans;
    for(int i=v.size()-1; i>0;i--){
        if(v[i] == v[i-1]){
            ans.push_back(v[i]);
            i--;
        }
    }
    if(ans.size() <= 1){
        cout << 0 << endl;
        return 0;
    }
    cout << ans[0]*ans[1] << endl;

    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N, M;
vector<vector<int> > G; // グラフ
vector<int> deg; // 各頂点の入次数

int dp[100100];
int main() {
    // 入力受け取り, 入次数も管理する
    cin >> N >> M;
    G.assign(N, vector<int>());
    deg.assign(N, 0);
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
        deg[y]++;
    }

    // source をキューに突っ込む
    queue<int> que;
    for (int v = 0; v < N; ++v) if (deg[v] == 0) que.push(v);

    // BFS
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            deg[nv]--; // エッジ (v, nv) を破壊する
            if (deg[nv] == 0) {
                que.push(nv); // それによって入次数が 0 にあったならキューに突っ込む
                chmax(dp[nv], dp[v] + 1); // さらにソースから nv までの再長距離が確定する
            }
        }
    }

    // 答え
    int res = 0;
    for (int v = 0; v < N; ++v) chmax(res, dp[v]);
    cout << res << endl;
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		int y = 0;
		
		if( a != 0 ){ a -= 1; } else { y = 1; }
		System.out.println((b / x - a / x) + y);
	}}
		

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;


int main() {

    ll N;

    cin >> N;

    ll count = 0, a;
    vector<ll> A(N + 1);

    rep(i, N + 1) {
        A[i] = 0;
    }

    rep(i, N) {
        cin >> a;
        if (a > N) {
            count++;
        }
        else if (A[a] < a) {
            A[a]++;
        }
        else {
            count++;
        }
    }

    rep(i, N + 1) {
        if (A[i] < i) {
            count += A[i];
        }
    }

    cout << count;

    return 0;
}

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

int main() {
   string n;cin>>n;
   if(n.at(n.length()-1)=='2'||n.at(n.length()-1)=='4'||n.at(n.length()-1)=='5'||n.at(n.length()-1)=='7'||n.at(n.length()-1)=='9'){
       cout<<"hon"<<endl;
       }else if(n.at(n.length()-1)=='0'||n.at(n.length()-1)=='1'||n.at(n.length()-1)=='6'||n.at(n.length()-1)=='8'){
         cout<<"pon"<<endl;
         }else if(n.at(n.length()-1)=='3') {
             cout<<"bon"<<endl;
             }

}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

vector<int> psum(const string &s){
    vector<int> res(s.size()+1);
    REP(i, s.size()){
        res[i+1] = res[i] + (s[i]=='A');
    }
    return res;
}

int main(){
    int q;
    string S, T;
    cin >> S;
    cin >> T;
    vector<int> SP = psum(S);
    vector<int> TP = psum(T);
    cin >> q;
    REP(i, q){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int sa = SP[b] - SP[a-1];
        int sb = b-a+1 - sa;
        int ta = TP[d] - TP[c-1];
        int tb = d-c+1 - ta;
        if(sa < ta){
            int diff = ta-sa;
            sa += diff;
            sb += diff;
        }
        if(sb < tb){
            int diff = tb-sb;
            sa += diff;
            sb += diff;
        }
        if(sa > ta && sb > tb){
            int diff = min(sa-ta, sb-tb);
            sa -= diff;
            sb -= diff;
        }
        //cerr << sa << "," << sb << " " << ta << "," << tb << endl;
        int diff = (sa-ta) + (sb-tb);
        cout << (diff%3==0 ? "YES" : "NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j&&s[i]==s[j]){
                cout<<"no"<<endl;
                return 0;
            }
        }
    }
    cout<<"yes"<<endl;
}

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

int main() {
  int n,k;
  cin >>n>>k;
  string s;
  cin>>s;
  s[k-1]='a'+(s[k-1]-'A');
  cout<<s<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  n = 2*m+1;
  vector<pair<int, int>> ans;
  int r;
  if(m % 2 == 0) r = m+1;
  else r = m;
  rep(i, m/2){
    ans.push_back(make_pair(i+1, r-i));
  }
  int l;
  l = r+1;
  rep(i, (m+1)/2){
    ans.push_back(make_pair(l+i, n-i));
  }
  rep(i, m){
    cout << ans.at(i).first << " " << ans.at(i).second << endl;
  }
  return 0;
}

Measured memory_bytes: 4228
#include<iostream>

using namespace std;

int main(){
	
	int high, side;
	
	for (;;){
		cin >> high >> side;
		if (high == 0 && side == 0){
			break;
		}

		for (int i = 0; i < high; i++){
			for (int o = 0; o < side; o++){
				if (i == 0 || i == high - 1 || o == 0 || o == side - 1){
					cout << "#";
				}
				else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	

	//system("pause");
	

}


Measured memory_bytes: 3116
S = input()
month_list = ["01","02","03","04","04","05","06","07","08","09","10","11","12"]

if S[0:2] in month_list:
    if S[2:4] in month_list:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if S[2:4] in month_list:
        print("YYMM")
    else:
        print("NA")

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    VL a(n);
    LL small = INF;
    int idx_small;
    LL large = -INF;
    int idx_large;
    REP(i,n){
        cin>>a[i];
        if(a[i] < small){
            small=a[i];
            idx_small = i;
        }
        if(a[i] > large){
            large=a[i];
            idx_large = i;
        }
    }

    VPII result;

    if(small>=0){ // plus
        REP(i,n-1){
            result.PB(MP(i+1,i+2));
        }
    }
    else if(large<=0){ //minus
        PER(i,n-1){
            result.PB(MP(i+2,i+1));
        }
    }
    else{ //mix
        if(abs(small) > abs(large)){
            REP(i,n){
                result.PB(MP(idx_small+1,i+1));
            }
            PER(i,n-1){
                result.PB(MP(i+2,i+1));
            }
        }
        else{
            REP(i,n){
                result.PB(MP(idx_large+1,i+1));
            }
            REP(i,n-1){
                result.PB(MP(i+1,i+2));
            }
        }
    }

    cout<<SIZE(result)<<endl;
    REP(i,SIZE(result)){
        cout<<result[i].first<<" "<<result[i].second<<endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k,a,b;
    cin>>k>>a>>b;
    int flag=0;
    for (int i=a;i<=b;i++) {
        if (i%k==0) {
            cout<<"OK"<<endl;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        cout<<"NG"<<endl;
    }
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		ArrayList<Integer> list = new ArrayList<>();
		int prev = 0;
		int idx = 0;
		int last = 1;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if (x == prev) {
				continue;
			}
			int count;
			if (map.containsKey(x)) {
				count = (list.get(map.get(x)) + last) % MOD;
			} else {
				count = last;
			}
			map.put(x, idx);
			last = count;
			idx++;
			prev = x;
			list.add(count);
		}
		System.out.println(last);
	}
}


Measured memory_bytes: 106168
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int N, M;
int X[100000];
int Y[100000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;

  int mm = 0;
  REP(i, M) {
    cin >> X[i];
  }
  sort(X, X + M);
  int sum = 0;
  REP(i, M) {
    if(i) {
      Y[i-1] = X[i] - X[i - 1];
      sum += Y[i-1];
    }
  }
  sort(Y, Y + M - 1, greater<int>());
  REP(i, (N-1)) {
    sum -= Y[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 1024
s=input()
K=int(input())
l=len(s)


L=[]

for i in range(l):
    L=L+[s[i]]

for i in range(l-1):
    L=L+[s[i]+s[i+1]]

for i in range(l-2):
    L=L+[s[i]+s[i+1]+s[i+2]]

for i in range(l-3):
    L=L+[s[i]+s[i+1]+s[i+2]+s[i+3]]
    
for i in range(l-4):
    L=L+[s[i]+s[i+1]+s[i+2]+s[i+3]+s[i+4]]


M=sorted(list(set(L)))

print(M[K-1])


Measured memory_bytes: 135692
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] alpha = {"A", "B", "C", "D", "E", "F"};
		String X = scan.next();
		String Y = scan.next();
		int XNum = 0;
		int YNum = 0;
		for(int i = 0; i < alpha.length; i++) {
			if(X.equals(alpha[i])) {
				XNum = i;
				break;
			}
		}
		for(int i = 0; i < alpha.length; i++) {
			if(Y.equals(alpha[i])) {
				YNum = i;
				break;
			}
		}
		if(XNum == YNum) {
			System.out.println("=");
		} else if(XNum > YNum) {
			System.out.println(">");
		} else if(XNum < YNum) {
			System.out.println("<");
		}
		scan.close();

	}

}


Measured memory_bytes: 21844
package main

import "fmt"

func stringToRunes(s string) (runes []rune) {
	runes = make([]rune, len(s))
	for i, r := range s {
		runes[i] = r
	}
	return
}

func runesToString(runes []rune) (s string) {
	s = ""
	for i := 0; i < len(runes); i++ {
		s += string(runes[i])
	}
	return
}

func main() {
	var s string
	fmt.Scan(&s)
	rs := stringToRunes(s)
	rs[3] = '8'
	fmt.Println(runesToString(rs))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    map<string,int> map;

    rep(i,n){
        string s; cin >> s;
        map[s]++;
    }
    cout<<"AC x "<<map["AC"]<<endl;
    cout<<"WA x "<<map["WA"]<<endl;
    cout<<"TLE x "<<map["TLE"]<<endl;
    cout<<"RE x "<<map["RE"]<<endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
// union by size + path having
class UnionFind {
public:
   vector <ll> par; // 各元の親を表す配列
   vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
   // Constructor
   UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
       for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
   }
   void init(ll sz_) {
       par.resize(sz_);
       siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
       for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
  }
 
   // Member Function
   // Find
   ll root(ll x) { // 根の検索
      while (par[x] != x) {
           x = par[x] = par[par[x]]; // x の親の親を x の親とする
       }
       return x;
  }
 
   // Union(Unite, Merge)
   bool unite(ll x, ll y) {
       x = root(x);
       y = root(y);
       if (x == y) return false;
       // merge technique（データ構造をマージするテク．小を大にくっつける)
       if (siz[x] < siz[y]) swap(x, y);
       siz[x] += siz[y];
       par[y] = x;
       return true;
  }
 
  bool same(ll x, ll y) { // 連結判定
       return root(x) == root(y);
  }
 
  ll size(ll x) { // 素集合のサイズ
      return siz[root(x)];
  }
};

int main(){

    ll n,m,k;
    cin >> n >> m >> k;

    UnionFind f(n);
    vector<set<ll>> g(n);

    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--; y--;
        g[x].insert(y);
        g[y].insert(x);
        f.unite(x,y);
    }

    rep(i,k){
        ll x,y;
        cin >> x >> y;
        x--; y--;
       
        if(!(f.same(x,y))) continue;
        
        g[x].insert(y);
        g[y].insert(x);
        
    }

    rep(i,n){
        cout << f.size(i)-1-g[i].size() << " ";
    }

    cout << endl;
}

Measured memory_bytes: 25856
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

signed main() {
	int n;
	cin >> n;
	map<int, int>ans = factaring(n);
	cout << n << ":";
	for (auto p : ans) {
		rep(i, p.second) {
			cout << " " << p.first;
		}
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 3132