akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    vector<int> A;
    long long ans=0;
    rep(i,N){
       int tmp;
       cin>>tmp;
       A.push_back(tmp); 
       ans+=tmp;
    }
    int Q;
    cin>>Q;
    vector<long long> B,C;
    rep(i,Q){
        long long b,c;
        cin>>b>>c;
        B.push_back(b);
        C.push_back(c);
    }
    map<long long ,long long> nums;//(数、個数)で持つ
    rep(i,N){
        if(nums.count(A[i])){
            nums[A[i]]++;
        }else{
            nums[A[i]]=1;
        }
    }

    rep(i,Q){
        //各クエリでmapを更新、何が0になって何が増えたのか、総和はどうなったかを更新
        if(!nums.count(B[i])){
            //Biに相当する数が数列上にいないなら前のans引継ぎ
            cout << ans << endl;
            continue;
        }
        if(B[i]>C[i]){
            //総和は減るはず
            ans=ans-(nums[B[i]]*B[i])+nums[B[i]]*C[i];//Biがnums[Bi]個へってCiがnums[B[i]]こ増えた
            cout << ans << endl;
                if(nums.count(C[i])){
                nums[C[i]]+=nums[B[i]];//いるならBiの個数を足す
                }else{
                    nums[C[i]]=nums[B[i]];//いないならBiそのもの
                }
                //Biの個数は0に
                nums[B[i]]=0;

        }else{
        //総和はふえるはず
            ans=ans-(nums[B[i]]*B[i])+nums[B[i]]*C[i];//Biがnums[Bi]個へってCiがnums[B[i]]こ増えた
            cout << ans << endl;
                if(nums.count(C[i])){
                nums[C[i]]+=nums[B[i]];//いるならBiの個数を足す
                }else{
                    nums[C[i]]=nums[B[i]];//いないならBiそのもの
                }
                //Biの個数は0に
                nums[B[i]]=0;   
        }

    }



    return 0;
}

Measured memory_bytes: 10288
/*
				   _ooOoo_
				  o8888888o
				  88" . "88
				  (| -_- |)
				  O\  =  /O
			   ____/`---'\____
			 .'  \\|     |//  `.
			/  \\|||  :  |||//  \
		   /  _||||| -:- |||||-  \
		   |   | \\\  -  /// |   |
		   | \_|  ''\---/''  |   |
		   \  .-\__  `-`  ___/-. /
		 ___`. .'  /--.--\  `. . __
	  ."" '<  `.___\_<|>_/___.'  >'"".
	 | | :  `- \`.;`\ _ /`;.`/ - ` : | |
	 \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
				   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		fozubaoyou    pass System Test!
		quoted from "https://codeforces.com/contest/472/submission/7996840"
*/
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
#define PI acos(-1)
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){

	int n,L;
	cin>>n>>L;
	vi a(n);
	int pos=-1;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>=L){
			pos=i+1;
			break;
		}
	}
	if(pos==-1){
		cout<<"Impossible"<<endl;
		return 0;
	}
	cout<<"Possible"<<endl;

	for(int i=0;i<pos-1;i++){
		cout<<i+1<<endl;
	}
	for(int i=n-1;i>=pos+1;i--){
		cout<<i<<endl;
	}
	cout<<pos<<endl;

}


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

int main() {
    vector<bool> v(11111, true);
    v[0] = v[1] = false;
    for (int i = 2; i <= 10010 / 2; i++) {
        for (int j = 2; j * i <= 10010; j++) {
            v[i * j] = false;
        }
    }

    vector<pair<int,int> > d;
    for (int i = 0; i <= 10010 ; i++) {
        if (v[i] && v[i+2]) d.push_back(pair<int,int>(i, i+2));
    }

    int n;
    while (cin >> n, n) {
        auto iter = upper_bound(d.begin(), d.end(), pair<int,int>(n - 2,n - 2)) - d.begin();
        while (d[iter].second > n) iter--;
        cout << d[iter].first << ' ' << d[iter].second << endl;
    }

    return 0;
}

Measured memory_bytes: 3068
using System;

namespace ALDS1_6_C
{
    public static class Sort
    {
        public delegate void SwapperAction<T>(ref T a, ref T b);
        public static void QuickSort<T>(this T[] a, SwapperAction<T> swapper) where T : IComparable
        {
            QuickSort(a, 0, a.Length - 1, swapper);
        }

        private static void QuickSort<T>(T[] a, int s, int t, SwapperAction<T> swapper) where T : IComparable
        {
            if (s < t)
            {
                int mid = Partition(a, s, t, swapper);
                QuickSort(a, s, mid - 1, swapper);
                QuickSort(a, mid + 1, t, swapper);
            }
        }
        private static int Partition<T>(T[] a, int s, int t, SwapperAction<T> swapper) where T : IComparable
        {
            int p = s;
            T x = a[t];
            for (int i = s; i < t; ++i)
            {
                if (a[i].CompareTo(x) <= 0) swapper.Invoke(ref a[p++], ref a[i]);
            }
            swapper.Invoke(ref a[p], ref a[t]);
            return p;
        }
    }
    class Program
    {
        struct Card : IComparable
        {
            public int num;
            public char kind;
            public int oldPos;
            public int CompareTo(object obj)
            {
                return num.CompareTo(((Card)obj).num);
            }
            public override string ToString()
            {
                return kind.ToString() + " " + num; 
            }

            public static Card Parse(string str)
            {
                var strs = str.Split(' ');
                return new Card() { kind = strs[0][0], num = int.Parse(strs[1]) };
            }

            public static void Swapper(ref Card a, ref Card b)
            {
                Card t = a;
                a = b;
                b = t;
            }
        }
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var cards = new Card[n];
            for (int i = 0; i < n; i++)
            {
                cards[i] = Card.Parse(Console.ReadLine());
                cards[i].oldPos = i;
            }
            cards.QuickSort(Card.Swapper);
            Console.WriteLine(IsStatble(cards) ? "Stable" : "Not stable");
            foreach (var card in cards) Console.WriteLine(card);
        }

        static bool IsStatble(Card[] cards)
        {
            bool isNull = true;
            Card pre=new Card();
            foreach (var card in cards)
            {
                if (isNull)
                {
                    pre = card;
                    isNull = false;
                }
                else if (card.num == pre.num && card.oldPos < pre.oldPos) return false;
                else pre = card;
            }
            return true;
        }
    }
}

Measured memory_bytes: 11904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long x = in.nextLong(), y = in.nextLong();
			long count = 1;

			if (x % y == 0) {
				out.println(-1);
				return;
			}

			long c = 2L;
			while (x <= Math.pow(10L, 18L)) {
				if (x*c % y != 0) {
					out.println(x*c);
					return;
				}
				c++;
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool has_key(T mp, U key) { return mp.find(key) != mp.end(); }
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll r;
        ll D;
        ll x;
        cin >> r >> D >> x;
        vll ans(11);
        ans[0] = x;
        rep(i, 1, 11) {
                ans[i] = r * ans[i-1] - D;
        }
        rep(i, 1, 11) {
                cout << ans[i] << endl;
        }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int prime(int n){
	for(long long  i = 2; i * i<= n; ++i){
		if(n % i == 0) return 1;
	}
	return 0;
}
using namespace std;
int main(){
	int n, i;
	cin >> n;
	for(i = n; prime(i); ++i);
	cout << i;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define SIZE 1000
int H,W;//H=???????????? W=??±?\???????
vector<vector<int> > ans(SIZE, vector<int>(SIZE, -1));
char chart[SIZE][SIZE];
void iscloud(){
    for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(chart[i][j]=='c'){
                    ans[i][j]=0;
                }
            }
        }
    return ;
}
void isleft(){
    bool isc=false;
    for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(chart[i][j]=='c'){
                    isc=true;
                    for(int f=j;f>=0;f--){
                        ans[H][f]=-1;
                    }
                }
                if(isc==true){break;}
            }
            if(isc==false){//??????c???????????´????????????
            for(int j=0;j<W;j++){
                ans[i][j]=-1;
            }
            break;
            }
            isc=false;
        }
return ;
}
void isright(){
    int time=1,ccount=0;
    for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(ans[i][j]==0){
                    for(int f=j+1;f<W;f++){
                    if(ans[i][f]==0){
                        break;
                    }
                    ans[i][f]=time;
                    time++;
                    }
                }
                time=1;
                ccount=0;
            }

        }
    return ;
}
void output(){
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(j==W-1){
                cout<<ans[i][j];
            }
            else{
            cout<<ans[i][j]<<" ";
            }
        }
        cout<<endl;
    }
    return;
}
int main(){
    cin>>H>>W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>chart[i][j];
        }
    }
iscloud();
isleft();
isright();
output();
    return 0;
}

Measured memory_bytes: 6608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

void work() {
    int n; cin>>n;
    set<int> s;
    for (int i = 0; i < n; ++i) {
        int a; cin>>a;
        if (s.count(a) != 0) {
            cout << "NO" << endl;
            return;
        }
        s.insert(a);
    }
    cout << "YES" << endl;
}

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

    return 0;
}


Measured memory_bytes: 9600
program test
implicit none
integer::i,n,check
character::S*100
check=0
read*,S
S=trim(S)
n=len(S)
do i=1,n
	if(mod(i,2)==1)then
    	if(S(i:i)=='L')then
        	check=check+1
         else 
         	check=check
         end if
    else 
    	if(S(i:i)=='R')then
        	check=check+1
         else 
         	check=check
         end if
    end if
end do
if(check==0)then 
	print*,'Yes'
else 
	print*,'No'
end if
end program test

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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 100005;

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

    string s; cin >> s;

    vector<string> d = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    int i = 0;
    int k = 0;
    while (s != d[i]) {
        i++;
    }
    while (d[(i+k) % sz(d)] != "SUN") {
        k++;
    }

    if (k == 0) k = 7;
    cout << k << endl;

    return 0;
}

Measured memory_bytes: 256
import heapq


def m():
    K, T = [int(x) for x in input().split(' ')]
    A = [int(x) for x in input().split(' ')]
    h = sorted([-x for x in A])

    tmp = 0
    suc = 0
    while len(h) > 0:
        suc += 1
        a = heapq.heappop(h)
        if tmp < 0:
            heapq.heappush(h, tmp)
        tmp = a + 1
    print(K - suc)


m()


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

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb(i) push_back(i)
#define fs first
#define sc second

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

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", " ;
	return out << "}" << endl;
}
template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

int main(){
	int w,h;
	cin >> w >> h;
	vector<pii> p(w+h);
	rep(i,w+h){
		cin >> p[i].fs; 
		p[i].sc = i >= w;
	}
	sort(p.begin(),p.end());
	
	ll cost =0;
	int cnt = 0;
	int pi=0,qi=0;
	rep(i,w+h){
		if(p[i].sc){
			cost += p[i].fs * (ll) max(w+1-qi,1);
			pi++;
		}else{
			cost += p[i].fs * (ll) max(h+1-pi,1);
			qi++;
		}
	}

	cout << cost << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
  int n;
  int a[110];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int a_max = 0;
  int a_min = 1000000010;
  for (int i = 0; i < n; i++) {
    a_max = max(a_max, a[i]);
    a_min = min(a_min, a[i]);
  }
  cout << a_max - a_min << endl;
}


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

using namespace std;

int main()
{
    int n,ma,mb;
    int inf = 1000000000;
    cin >> n >> ma >> mb;
    int dp[n + 1][n * ma + 1][n * mb + 1];
    int array[n + 1][3];
    for(int i = 1;i <= n;i++){
        cin >> array[i][0] >> array[i][1] >> array[i][2];
    }
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n*ma;j++){
            for(int k = 0;k <= n*mb;k++)
            dp[i][j][k] = inf;
        }
    }
    dp[0][0][0] = 0;
    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= n*ma;j++){
            for(int k = 0;k <= n*mb;k++){
                dp[i][j][k] = dp[i - 1][j][k];
                if(j >= array[i][0] && k >= array[i][1]){
                if(dp[i - 1][j - array[i][0]][k - array[i][1]] == inf)continue;
                dp[i][j][k] = min(dp[i][j][k],dp[i - 1][j - array[i][0]][k - array[i][1]] + array[i][2]);
            }
        }
    }
    }
    int ans = inf;
    for(int i = 1;i <= n*ma;i++){
        for(int j = 1;j <= n*mb;j++){
        if(i*mb == j*ma)ans = min(ans,dp[n][i][j]);
        }
    }
        if(ans == inf)cout << -1;
        else cout << ans;
        return 0;
    }


Measured memory_bytes: 23424
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

//A 65
//a 97
//pairの比較関数(昇順)
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  int n,k;cin>>n>>k;
  VI  h(n);
  int ans=0;
  REP(i,n){
    cin>>h[i];
    if(h[i]>k-1){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF=1e18+10;
const int inf=1e9+10,dx[]= {0,0,1,-1,1,-1,1,-1},dy[]= {1,-1,0,0,1,1,-1,-1};
ll MOD=1e9+7;
ld eps=1e-7,pi=acos(-1);

int n,k,h[100100];

int mem[100100];

int solve(int i)
{
if(i==n)return 0;

if(mem[i]!=-1)return mem[i];
int res=0;

if(i+1<n)
res=abs(h[i]-h[i+1])+solve(i+1);

for(int j=2;j<=k;j++)
if(i+j<n)
res=min(res,abs(h[i]-h[i+j])+solve(i+j));
else
break;

return mem[i]=res;
}

int main()
{

scanf("%d %d",&n,&k);
for(int i=0;i<n;i++)
scanf("%d",&h[i]);

memset(mem,-1,sizeof mem);


printf("%d\n",solve(0));

return 0;
}


Measured memory_bytes: 5760
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}
 
class Sol{
	public void Solve(){
		
		long mod = (long) 1e9 + 7;
		long[] frac = new long[N+1];
		frac[0] = 1;
		for(int i=1;i<=N;i++) frac[i] = (frac[i-1] * i) % mod;
		List<Pair> L = new List<Pair>();
		for(int i=0;i<N;i++){
			L.Add(new Pair(A[i], 1));
		}
		for(int i=0;i<N;i++){
			L.Add(new Pair(B[i], -1));
		}
		
		L.Sort((p, q) => p.Val.CompareTo(q.Val));
		long ans = 1;
		List<Pair> tot = new List<Pair>();;
		long sig = 0;
		foreach(var p in L){
			sig += p.Sig;
			tot.Add(p);
			if(sig == 0){
				int[] sum = new int[tot.Count + 1];
				for(int i=0;i<tot.Count;i++){
					int inc = tot[i].Sig == tot[0].Sig ? 0 : 1;
					sum[i+1] = sum[i] + inc;
				}
				int NN = tot.Count / 2;
				
				long pat = 1;
				int cnt = 0;
				for(int i=tot.Count - 1;i>=0;i--){
					if(tot[i].Sig != tot[0].Sig) continue;
					pat *= NN - sum[i] - cnt;
					pat %= mod;
					cnt++;
				}
				
				ans *= pat;
				ans %= mod;
				tot.Clear();
			}
		}
		
		Console.WriteLine(ans);
		
		
	}
	
	class Pair{
		public int Val, Sig;
		public Pair(int val, int sig){
			Val = val; Sig = sig; 
		}
	}
	
	
	int N;
	int[] A,B;
	public Sol(){
		N = ri();
		A = new int[N];
		for(int i=0;i<N;i++) A[i] = ri();
		B = new int[N];
		for(int i=0;i<N;i++) B[i] = ri();
	}
 
	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

Measured memory_bytes: 30676
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;

int main (void){
  
    vector <double> h(500,0);
    int i = 0,j = 0,k = 0,l = 0;
    double max = 0;
    double min = 0;
    while(cin >> h[i++]);
    sort(h.begin(),h.end(),greater<double>());
    //cout << h[i-2] << endl;
    printf("%.1f\n",h[0]-h[i-2]);
    return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;

int main()
{
    int X;
    cin >> X;
    cout << (X >= 30 ? "Yes" : "No") << endl;
    return 0;
}

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

string a;
int main()
{
	int i;
	cin >> a;
	for (i = 0; i < a.size(); i++) if (a[i] != a[a.size() - 1 - i]) {cout << "No"; return 0;}
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

#define rep(a) _rep(0,int(a))
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
#define int long long

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}

int a, b, c, k,ans;
signed main() {
	cin >> a >> b >> c >> k;
	if (k <= a) {
		ans = 1 * k;
	}
	else if (k <= a+b) {
		ans = a;
	}
	else {
		ans = a - (k - a - b);
	}
	cout << ans;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,k,m;
string s,t;

int main() {
  cin >> s;
  int a=count(all(s),'a'), b=count(all(s),'b'), c=count(all(s),'c');
  if(a==b && b==c)
  cout << "YES" << endl;
  else if(max({a,b,c})-min({a,b,c})<2)
  cout << "YES" << endl;
  else 
  cout << "NO" << endl;
}

Measured memory_bytes: 512
/**
 *   author: Shubham Srivastava
 *   created: 12 January 2020  17:39:09
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,t;cin>>n>>t;
    map <int,int> m2;
    map <ll,ll> m;
    ll ans = 0, w = 0;
    for(int i=0;i<t;i++){
    	ll a;cin>>a;
    	string s;cin>>s;
    	if(m2[a] == 0){
    		m[a] += 1;
    		if(s == "AC"){
    			m2[a] = 1;
    			w += m[a]-1;
    			ans++;
    		}
    	}
    }
    cout<<ans<<" "<<w<<endl;
return 0;
}

Measured memory_bytes: 11264
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int x;
	cin>>x;
	vector<int>a(4);
	for(int i=3;i>=0;--i)
	{
		a[i]=x%10;
		x/=10;
	}
	if(a[1]!=a[2])
	{
		cout<<"No\n";
		return 0;
	}
	if(a[0]==a[1]||a[2]==a[3])
	{
		cout<<"Yes\n";
		return 0;
	}
	cout<<"No\n";
}

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

int main(){
    int n;
    cin>>n;
    
    vector<long long> l(n+1);
    l[0]=2,l[1]=1;

    for(int i=2; i<=n; i++){
        l[i]=l[i-1]+l[i-2];
    }

    cout<<l[n]<<endl;
}

Measured memory_bytes: 256
def findSUM(n):
    sum = 0
    while (n > 0):
        sum += n % 10
        n //= 10
    return sum

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

total = 0
for i in range(N+1):
    sum = findSUM(i)
    if (sum >= A and sum <= B):
        total += i

print(total)


Measured memory_bytes: 2940
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	var begin, end int
	var started bool
	for i, r := range s {
		if !started && r == 'A' {
			begin = i
			started = true
		}
		if started && r == 'Z' {
			end = i
		}
	}
	fmt.Println(end - begin + 1)
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;

const int M = 1e9;

int H, W, h, w;

void read() {
    cin >> H >> W >> h >> w;
}

void kill() {
    if (H % h == 0 && W % w == 0) {
        cout << "No\n";
        exit(0);
    }

    cout << "Yes\n";
    int a = M / (h * w);
    int b = -a * (h * w - 1) - 1;
    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j) {
            cout << (i % h == 0 && j % w == 0 ? b : a) << " \n"[j == W];
        }
}

int main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  kill();
}



Measured memory_bytes: 2816
// AtCoder ABC127: C - Prison
// 2019.9.8 bal4u

#include <stdio.h>

//// 高速入力
#if 1
int getchar_unlocked(void);
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int main()
{
	int l, r, ll, rr, N, M;
	
	N = in(), M = in();
	ll = 1, rr = N; 
	while (M--) {
		l = in(), r = in();
		if (l > ll) ll = l;
		if (r < rr) rr = r;
	}
	if (rr >= ll) printf("%d\n", rr-ll+1);
	else puts("0");
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    vector<long long int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    
    for (int t = 1; t <= N; ++t) {
        if (t > K) {
            cout << (A[t-1] > A[t - K - 1] ? "Yes" : "No") << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4840
#include <stdio.h>

int main(void){
	int i,n,c0=0,c1=0,c2=0,c3=0;
  	char s[10];
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%s",&s);
      if(strcmp(s,"AC")==0){
        c0++;
      }
      else if(strcmp(s,"WA")==0){
        c1++;
      }
      else if(strcmp(s,"TLE")==0){
        c2++;
      }
      else{
        c3++;
      }
    }
      printf("AC x %d\n",c0);
      printf("WA x %d\n",c1);
      printf("TLE x %d\n",c2);
      printf("RE x %d\n",c3);
  	
	return 0;
}

Measured memory_bytes: 1732
#pragma GCC target (*sse4.2*)
#pragma GCC optimization ("O3")
#pragma GCC optimize ("Ofast")
#define mod 1000000007
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PB push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define vvii vector<vii>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read(x) long long x;cin>>x;
#define FOR(a,b,c,d) for(int a=b;a<=c;a+=d)
#define MP make_pair
#define F first
#define S second
#define debug(x) cout<<("#x)<<": "<<(x)<<"\n"
#define SZ(x) x.size()
#define INF (1<<63)-1

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double d64;

ull modpow(ull a,ull b){
    if(b==0)return 1;
    ull u=modpow(a,b/2);
    u*=u;
    if(b&1)u*=a;
    return u;
}

int main(){
fast
read(n);
ull sum=0;

    sum=modpow(n,1)+modpow(n,2)+modpow(n,3);
cout<<sum;

return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

double heron(double a, double b, double c){
  double s = (a + b + c) / 2.0;
  return sqrt(s * (s-a) * (s-b) * (s-c));
}

int main(){
  double a,l,x;
  while(cin >> a >> l >> x) printf("%.10f\n",heron(a,l,l) + heron(l,(l+x)/2.0,(l+x)/2.0)*2.0);
}

Measured memory_bytes: 1240
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;

return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int a,b;cin>>a>>b;
	if(b<a)cout<<a-1<<endl;
	else cout<<a<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int f[100];

int main(){
  int n, i;
  f[0] = f[1] = 1;
  scanf("%d", &n);
  for(i = 2; i <= n; ++i) f[i] = f[i - 1] + f[i - 2];
  printf("%d\n", f[n]);
  return 0;
}



Measured memory_bytes: 2036
#include <stdio.h>

#define MOD 1000000007

int main() {
  int h, w, k;
  scanf("%d%d%d", &h, &w, &k);
  int dp[h+1][w];
  for (int i=0; i<h+1; i++) {
    for (int j=0; j<w; j++) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for (int i=1; i<h+1; i++) {
    for (int k=0; k<(1<<(w-1)); k++) {
      int check = 1;
      for (int l=0; l<w-2; l++) {
        if (((k>>l)&3) == 3) {
          check = 0;
          break;
        }
      }
      if (check == 0) continue;
      for (int j=0; j<w; j++) {
        if (j<w-1 && ((k>>j)&1) == 1) {
          dp[i][j+1] += dp[i-1][j];
          dp[i][j+1] %= MOD;
        }else if (j>0 && ((k>>(j-1))&1) == 1) {
          dp[i][j-1] += dp[i-1][j];
          dp[i][j-1] %= MOD;
        }else {
          dp[i][j] += dp[i-1][j];
          dp[i][j] %= MOD;
        }
      }
    }
  }
  printf("%d\n", dp[h][k-1]);
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int consn = n;
    int sn = 0;
    while(n != 0){
        sn += n % 10;
        n /= 10;
    }
    if (consn%sn == 0) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

cnt = [0] * 9
for i in a:
    x = min(i // 400, 8)
    if x >= 8:
        cnt[8] += 1
    else:
        cnt[x] = 1

if sum(cnt[:8]) == 0:
    l = 1
    r = cnt[8]
else:
    l = sum(cnt[:8])
    r = l+cnt[8]
print(l, r)

Measured memory_bytes: 9204
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        n: usize,
        k: usize,
        r: i64,
        s: i64,
        p: i64,
        t: chars,
    }

    let mut ans = 0;

    for i in 0..k {
        ans += solve(
            i,
            'x',
            k,
            &t,
            &[r, s, p],
            &mut vec![vec![None; 4]; (n + k - 1) / k],
        );
    }

    println!("{}", ans);
}

fn enc(c: char) -> usize {
    match c {
        'r' => 0,
        's' => 1,
        'p' => 2,
        'x' => 3,
        _ => unreachable!(),
    }
}

fn sc(a: char, b: char, st: &[i64]) -> i64 {
    match (a, b) {
        ('r', 's') => st[0],
        ('s', 'p') => st[1],
        ('p', 'r') => st[2],
        _ => 0,
    }
}

fn solve(
    i: usize,
    prev: char,
    k: usize,
    t: &[char],
    st: &[i64],
    tbl: &mut Vec<Vec<Option<i64>>>,
) -> i64 {
    if i >= t.len() {
        return 0;
    }

    if let Some(ret) = tbl[i / k][enc(prev)] {
        return ret;
    }

    let mut ret = 0;

    for &cur in ['r', 's', 'p'].iter() {
        if cur == prev {
            continue;
        }

        let score = solve(i + k, cur, k, t, st, tbl) + sc(cur, t[i], st);
        ret = std::cmp::max(ret, score);
    }

    tbl[i / k][enc(prev)] = Some(ret);
    return ret;
}


Measured memory_bytes: 28412
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, ans;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    set<int> S;
    map<int, int> mem;
    rep(i, 0, n) {
        int a;
        cin >> a;
        S.insert(a);
        mem[a]++;
    }
    for (auto itr = S.begin(); itr != S.end(); ++itr) {
        if (mem[*itr]%2) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
N = int(input())


As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

mae = -1
point = 0

for i, a in enumerate(As):
    if mae + 1 == a:
        point += Cs[(a - 1)-1]
    point += Bs[a-1]
    mae = a

    # print(point)
print(point)


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

int main() {
	int W, H, x, y, r;
	cin >> W;
	cin >> H;
	cin >> x;
	cin >> y;
	cin >> r;

	if (W >=(x+r) && 0<=(x-r) && H >= (y + r) && 0 <= (y - r)) {
			cout << "Yes" << endl;
	}
	else {
		cout <<"No"<< endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

vector<int> to[100005];
vector<bool> d(100005);
vector<bool> visited(100005,0);
bool flag = 1;
void dfs(int v, int p=-1) {
  for (auto u : to[v]) {
    if (u == p) continue;
    if(visited[u]){
      if(d[u]!=(1-d[v]))flag=0;
      continue;
    }
    visited[u]=1;
    d[u] = 1-d[v];
    dfs(u,v);
  }
}

int main() {
  ll n,m;
  cin >> n >> m;
  rep(i,m) {
    int u,v;
    cin >> u >> v;
    --u; --v;
    to[u].push_back(v);
    to[v].push_back(u);
  }
  d[0]=0;
  //flag=1;
  visited[0]=1;
  dfs(0);
  if(flag){
    ll c0 =0,c1=0;
    rep(i,n){
      if(d[i]==0)c0++;
      else c1++;
    }
    ll ans = c0*c1-m;
    cout << ans << endl;
  }else{
    ll ans= n*(n-1)/2LL - m;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
const int mod=1e9+7;

int main(){
    int n;cin>>n;
    ll a[n];rep(i,n)cin>>a[i];
    ll ans=0;
    bool flag=1;
    while(flag){
        flag=0;
        rep(i,n){
            if(a[i]>=n){
                ll p=a[i]/n;
                ans+=p;          
                a[i]-=p*n;
                flag=1;
                rep(j,n){
                    if(j!=i)a[j]+=p;
                }
            }
        }
        if(!flag)break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  long long n,h[100010],dp[100010];
  cin>>n;
  for(int i=1;i<=n;++i)
    cin>>h[i];
  dp[1]=0;
  dp[2]=abs(h[1]-h[2]);
  for(int i=3;i<=n;++i)
  {
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1792
program prob4
    implicit none
    integer :: n, i, ans
    character(100005) :: s
    read(*,*) s
    n = len_trim(s) 
    ans = 0
    do i = 1, n-1
        if(s(i:i) /= s(i+1:i+1)) then
            ans = ans + 1
        end if
    end do
    write(*,*) ans

    stop
contains
end program prob4

Measured memory_bytes: 3128
import math
N = int(input())
A = list(map(int,input().split()))
dp_left=[0]*(N+1)
dp_right=[0]*(N+1)
for i in range(N):#左から累積GCD
  dp_left[i+1]=math.gcd(dp_left[i],A[i])
  dp_right[N-i-1]=math.gcd(dp_right[N-i],A[N-1-i])#右から累積GCD

ans = 0
for i in range(N):
  ans = max(ans,math.gcd(dp_left[i],dp_right[i+1]))
print(ans)

Measured memory_bytes: 20660
#include <iostream>
#include <string>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(void)
{
  string today;
  string tomorrow;
  
  cin >> today;
  
  if(today=="Sunny") tomorrow="Cloudy";
  else if(today=="Cloudy") tomorrow="Rainy";
  else tomorrow="Sunny";
  
  cout << tomorrow << endl;
  return 0;
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    long tot = 0;
    long r = 0, g = 0, b = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
            r++;
        if (s[i] == 'G')
            g++;
        if (s[i] == 'B')
            b++;
    }

    rep(i, 0, n - 2) rep(j, i, n - 1)
    {
        int k = 2 * j - i;
        if (k > n)
            continue;
        if (s[i - 1] != s[j - 1] && s[j - 1] != s[k - 1] && s[i - 1] != s[k - 1])
        {
            tot++;
            continue;
        }
    }
    cout << (r * g * b) - tot << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false); 

    ll n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        --a[i];
    }
    vector<int> r,visited(n);
    int now=0,cnt=0;
    while (1) {
        r.push_back(now);
        ++visited[now];
        ++cnt;
        now=a[now];
        if (visited[now]==1) break;
    }
    int s=0;
    rep(i,r.size()) {
        if (r[i]==now) s=i;
    }
    if (k<=s) cout << r[k]+1 << endl;
    else {
        ll j=(k-s)%(cnt-s);
        cout << r[s+j]+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 5916
#include <stdio.h>

int n_buka[200001];

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


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e17;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

map <int, int> mp;

signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int n, m, lcm;
   string s, t;
   cin >> n >> m >> s >> t;
   lcm = (n * m) / __gcd(n, m);
   if (s[0] != t[0]) {
      cout << -1;
      return 0;
   }
   string u;
   //for (int i = 0; i<= lcm; i++) u += '1';
   u[0] = s[0];
   for (int i = 1; i < n; i++) {
      mp[i * lcm  / n] = s[i];
   }  
   for (int i = 1; i < m; i++) {
      if (mp[i * lcm / m] == 0 || mp[i * lcm / m] == (int)t[i]); 
      else {
         cout << -1;
         return 0;
      }
   } 
   cout << lcm;
}


Measured memory_bytes: 10880
//
// Created by kuroneko on 2019-09-15.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    int N, M; cin >> N >> M;
    priority_queue<ll> a;
    for (int i = 0; i < N; i++) {
        ll tmp; cin >> tmp;
        a.push(tmp);
    }

    for (int i = 0; i < M; i++) {
        ll top = a.top(); a.pop();
        top /= 2;
        a.push(top);
    }

    ll res = 0;
    while (!a.empty()) {
        res += a.top();
        a.pop();
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
	long long int ans=0,N,x;
	vector<long long int>A,B,C;
	cin>>N;
	for(long long int i=0;i<N;i++){
		cin>>x;
		A.push_back(x);
	}
	sort(A.begin(),A.end());
	for(long long int i=0;i<N;i++){
		cin>>x;
		B.push_back(x);
	}
	sort(B.begin(),B.end());
	for(long long int i=0;i<N;i++){
		cin>>x;
		C.push_back(x);
	}
	sort(C.begin(),C.end());
	for(long long int i=0;i<N;i++){
		long long int lit=(lower_bound(A.begin(),A.end(),B[i])-A.begin());
		long long int uit=(C.end()-upper_bound(C.begin(),C.end(),B[i]));
		ans+=lit*uit;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3316