akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 modpow(i64 a, int p = MOD - 2)
{
	if (p == 0) return 1;
	i64 ret = modpow(a, p / 2);
	ret = ret * ret % MOD;
	if (p % 2 == 1) ret = ret * a % MOD;
	return ret;
}

struct segtree
{
	static const int DEPTH = 19;
	static const int N = 1 << DEPTH;

	int val[2 * N];

	void init()
	{
		for (int i = 0; i < 2 * N; ++i) val[i] = 0;
	}

	void incl(int p, int v)
	{
		p += N;
		while (p) {
			val[p] += v;
			p >>= 1;
		}
	}

	int query(int L, int R)
	{
		L += N; R += N;
		int ret = 0;
		while (L < R) {
			if (L & 1) ret += val[L++];
			if (R & 1) ret += val[--R];
			L >>= 1; R >>= 1;
		}
		return ret;
	}
};
int N, P[505050];
vector<int> uus;
bool used[505050];
segtree seg;
i64 invs[505050];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", P + i);
		--P[i];
	}
	invs[0] = 0;
	for (int i = 1; i <= N; ++i) invs[i] = modpow(i);

	i64 mult = 1;
	int uu = 0;

	for (int i = 0; i < N; ++i) {
		if (P[i] >= 0) used[P[i]] = true;
	}
	for (int i = 0; i < N; ++i) if (!used[i]) uus.push_back(i);

	seg.init();

	i64 ret = 0;
	i64 ap = 0;
	i64 waf = uus.size() * (uus.size() - 1) / 2 % MOD;
	waf = waf * invs[uus.size()] % MOD;
	if (uus.size() > 0) waf = waf * invs[uus.size() - 1] % MOD;

	i64 fuee = 1;
	int pohe = 0;
	for (int i = 0; i < N; ++i) {
		if (P[i] == -1) {
			++pohe;
			fuee = fuee * pohe % MOD;
		}
	}

	i64 m2 = 1;
	for (int i = N - 1; i >= 0; --i) {
		if (P[i] == -1) {
		//	ADD(ret, ap);
			ADD(ret, (waf * uu % MOD + ap * invs[uus.size()]) % MOD * m2 % MOD * fuee % MOD);
///			printf("%lld\n", (waf * uu + ap * invs[uus.size()]) % MOD * m2 % MOD * fuee % MOD);
//			printf("%lld %lld\n", uu, ap);
			++uu;
			mult = mult * uu % MOD;
		} else {
			int lt = lower_bound(uus.begin(), uus.end(), P[i]) - uus.begin();
			int gt = uus.size() - lt;
	//		int gt = (uus.size() - (lower_bound(uus.begin(), uus.end(), P[i]) - uus.begin()));
//			int lt = uus.size() - lt;
//			printf("%d %d\n", lt, gt);
			ADD(ap, gt);
			ADD(ret, (seg.query(0, P[i]) + lt * invs[uus.size()] % MOD * uu) % MOD * m2 % MOD * fuee);
			seg.incl(P[i], 1);
		}
		m2 *= N - i;
		m2 %= MOD;
	}
//	printf("%lld\n", mult);

	ADD(ret, mult);
//	ADD(ret, 1);
	//ret = ret * mult % MOD;

	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 12528
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in1(a);
	cout<<a*(1+a*(1+a));
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String x = sc.next();
            if (x.equals("0")) return;
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += Character.getNumericValue(x.charAt(i));
            }
            System.out.println(sum);
        }
    }
}



Measured memory_bytes: 26560
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int x,y,step=0;
	cin>>x>>y;
	step+=abs(abs(x)-abs(y));
	if(x==y)
	{
		cout<<0;
		return 0;	
	}
	if(x==0)
	{
		if(y>0) cout<<step;
		else cout<<step+1;
		return 0;	
	}
	else if(y==0)
	{
		if(x>0) cout<<step+1;
		else cout<<step;
		return 0;
	}
	else if(abs(x)==abs(y))
	{
		cout<<1;
		return 0;	
	}
	else if((x>0&&y<0)||(x<0&&y>0))
	{
		cout<<step+1;
		return 0;
	}
	else if(abs(x)<abs(y))
	{
		if(x<0&&y<0)cout<<step+2;
		else cout<<step;
		return 0;	
	}
	else 
	{
		if(x<0&&y<0)cout<<step;
		else cout<<step+2;
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	int k;
	cin >> s >> k;
	
	int n = s.size();
	vector<string> str;
	
	for(int i = 0; i < n; ++i) {
		for(int j = 1; j <= k; ++j) {
			string tmp = s.substr(i, j);
			str.push_back(tmp);
		}
	}
	
	sort(str.begin(), str.end());
	str.erase(unique(str.begin(), str.end()), str.end());
	
	cout << str[k - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	if (abs(a - x) < abs(b - x))
	{
		cout << "A" << endl;
	}
	else
	{
		cout << "B" << endl;
	}

	return 0;
}

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

using namespace std;

bool match(char a, char b);

int lcs(string a, string b) {
	if (a.size() == 0 || b.size() == 0) return 0;
	int dp[a.size()+1][b.size()+1];

	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < b.size(); j++) {
			if (i == 0 && j == 0) {
				if (match(a[i], b[j])) dp[i][j] = 1;
				else dp[i][j] = 0;
			} else if (i == 0) {
				if (match(a[i], b[j])) dp[i][j] = 1;
				else {
					if (dp[i][j-1] == 1) dp[i][j] = 1;
					else dp[i][j] = 0;
				}
			} else if (j == 0) {
				if (match(a[i], b[j])) dp[i][j] = 1;
				else {
					if (dp[i-1][j] == 1) dp[i][j] = 1;
					else dp[i][j] = 0;
				}
			} else {
				if (match(a[i],b[j])) {
					dp[i][j] = max(max(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1]+1);
				} else {
				   	dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
				}
			}
		}
	}

//	for (int i = 0; i < a.size(); i++) {
//		for (int j = 0; j < b.size(); j++) {
//			cout << dp[i][j] << ' ';
//		}
//		cout << endl;
//	}

	return dp[a.size()-1][b.size()-1];
}

bool match(char a, char b) {
	switch (a) {
		case '(': return b == ')'; 
		case ')': return b == '('; 
		case '{': return b == '}'; 
		case '}': return b == '{'; 
		case '[': return b == ']'; 
		case ']': return b == '['; 
	}
}

int main() {
	string s; getline(cin, s);
	string::size_type iwi_index = s.find("iwi");
	string head, tail;
	head = s.substr(0, iwi_index);
	tail = s.substr(iwi_index+3, s.size());
	reverse(tail.begin(), tail.end());
	cout << 2*lcs(head, tail) + 3 << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<double> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    double sum=0;
    sum+=(vec.at(0)+vec.at(1))/2;
    for(int i=2;i<n;i++){
        sum = (sum + vec.at(i))/2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n, m, ans = 0;
    vector<int> num;
    vector<bool> pos;
    cin >> n >> m;
    num.assign(n, 1);
    pos.assign(n, false);
    pos[0] = true;
    for(int i=0;i<m;i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if(pos[x]){
            pos[y] = true;
            if(num[x] == 1)pos[x] = false;
        }
        num[x]--;
        num[y]++;
    }
    for(int i=0;i<n;i++){
        if(pos[i])ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
/*
 © 2020-08-29 06:57:42 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  float d, t, s; cin >> d >> t >> s;
  if(d/s <= t) cout << "Yes" << ENDL;
  else cout << "No" << ENDL;
  return 0;
}


Measured memory_bytes: 3712
N,sections=int(input()),[]

for i in [0]*N:
    x,l=map(int,input().split())
    sections.append((x+l,x-l))

sections.sort()

res=N
r,l=sections.pop(0)
for nr,nl in sections:
    if nl<r:
        res-=1
    else:
        r=nr
print(res)

Measured memory_bytes: 84048
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ArrayList<Integer> cases = new ArrayList<Integer>();
		int count = 0;
		String line;
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			while (true) {
				line = buf.readLine();
				cases.add(Integer.parseInt(line));
				if (cases.get(count) == 0)
					break;
				count++;
			}
			for (int i = 0; i < cases.size(); i++) {
				if (cases.get(i) == 0)
					break;
				System.out.println("Case " + (i + 1) + ": " + cases.get(i));
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 27968
#include<cstdio>
#include<cstring>
char s[200005];

int main(){
    scanf("%s",s+1);
    int n = strlen(s+1);
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        int u = s[i]-'0';
        cnt = (cnt+u)%9;
    }
    if(cnt==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1852
import java.io.*;
import java.util.ArrayDeque;

public class Main{
	public static void main(String [] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		ArrayDeque<Integer> place=new ArrayDeque<Integer>();
		ArrayDeque<lake> l=new ArrayDeque<lake>();
		char[] c=br.readLine().toCharArray();
		int totalarea=0;
		for (int i=0;i<c.length;i++){
			if (c[i]=='\\'){
				place.push(i);			
			}else if (c[i]=='/'){
				if (!place.isEmpty()){
					int b=place.pop();
					int a=i-b;
					totalarea+=a;
					while (!l.isEmpty() && l.getFirst().getnum()>b){
						a+=l.getFirst().getarea();
						l.pop();
					}
					l.push(new lake(a,i));
					
				}
			}
		}
		pw.println(totalarea);
		pw.print(l.size());
		for (;!l.isEmpty();){
			pw.print(" "+l.getLast().getarea());
			l.removeLast();
		}
		pw.println();
		pw.close();
	}
}

class lake{
	private int area,num;
	public lake(int a,int i){
		this.area=a;
		this.num=i;
	}
	public int getarea(){
		return this.area;
	}
	public int getnum(){
		return this.num;
	}
}

Measured memory_bytes: 25864
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int x[105];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
      cin>>x[i];
   } 
   int mn=1e9;

   for(int i=1;i<=100;i++)
   {
      int s=0;
      for(int j=1;j<=n;j++)
      {
         s+=pow(i-x[j],2);
      }
      mn=min(mn,s);
   }
   cout<<mn;
// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

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

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

    set<int> integer;
    for(int i=0; i<n; i++){
        int p;
        cin >> p;
        integer.insert(p);
    }

    int ans = -1;
    for(int i=-1; i<=101; i++){
        if(integer.find(i) == integer.end()){
            if(abs(x - i) < abs(x - ans)) ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
int a[200500];
int t[200500];
int d[200500];
int p[200500];
void yagamiraito(int x,int y)
{
    if(y-x>1)
    {
        int m = x+(y-x)/2;
        int p = x,q = m,i = x;
        yagamiraito(x,m);
        yagamiraito(m,y);
        while(p<m||q<y)
        {
            if(q>=y||(p<m&&d[p]<=d[q]))
                t[i++] = d[p++];
            else
            {
                t[i++] = d[q++];
            }
        }
        for(i = x;i<y;i++)
            d[i] = t[i];
    }
}

int main (void)
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(n==1)
    {
        printf("0\n");
        return 0;
    }
    memset(p,0,sizeof(p));
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        p[a[i]]++;
    }
    memset(d,0,sizeof(d));
    int num = 0;
    for(int i=1;i<=n;i++)
    {
        if(p[i])
            d[++num] = p[i];
    }
    yagamiraito(1,num+1);
    int x = num - k;
    if(x<1)
    {
        printf("0\n");
        return 0;
    }
    int sum = 0;
    for(int i=1;i<=x;i++)
        sum+=d[i];
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll n;
	cin >> n;
	vector<ll> a;
	a.push_back(2);
	a.push_back(1);
	loop(i, 2, n+1){
		a.push_back(a[i-2]+a[i-1]);
	}
	cout << a[n] << endl;
	return 0;
}

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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

// --------------------------------------

string s;

void input()
{
  cin >> s;
}

void solve()
{
  int cnt = 0;
  for(int i = 0; i < s.length(); i++)
  {
    if(s[i] == s[i-1])
    {
      s[i] = s[i] == '0' ? '1' : '0';
      cnt++;
    }
  }
  
  cout << cnt;
}

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

Measured memory_bytes: 512
n,m,q=map(int,input().split())
g=[[0]*n for _ in [0]*n]
for i in range(m):
    l,r=map(int,input().split())
    l-=1
    r-=1
    g[n-l-1][r]+=1
for i in range(n):
    for j in range(n-1):
        g[i][j+1]+=g[i][j]

for i in range(n):
    for j in range(n-1):
        g[j+1][i]+=g[j][i]

for i in range(q):
    p,w=map(int,input().split())
    p-=1
    w-=1
    print(g[n-1-p][w])
    
    


Measured memory_bytes: 58224
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);	
	ll n;
	cin >> n;
	ll ans = 0;
	ll k = 1;
	while(n>=1){
		ans += k;
		k*=2;
		n/=2LL;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 1000000000
static const int MAX=10004;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n;
vector<P> adj[MAX];

void dijkstra(){
    priority_queue<P> PQ;
    int color[MAX];
    int d[MAX];
    rep(i,n){
        d[i] = INF;
        color[i] = WHITE;
    }
    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = GRAY;

    while (!PQ.empty()){
        P f = PQ.top();
        PQ.pop();
        int u = f.second;
        color[u] = BLACK;
        if (d[u] < f.first * (-1)) continue;
        rep(j,adj[u].size()){
            int v = adj[u][j].first;
            if (color[v] == BLACK) continue;
            if (d[v] > d[u] + adj[u][j].second){
                d[v] = d[u] + adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v] = GRAY;
            }
        }
    }
    rep(i,n) cout << i << " " << (d[i] == INF ? -1:d[i]) << endl;
}
int main() {
    int k,u,v,c;
    cin >> n;
    rep(i,n){
        cin >> u >> k;
        rep(j,k){
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    
    return 0;
}


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

vector<int> route[200005];
vector<bool> visited(200005,0);
int s[200005];

void dfs(int v){
    s[v]=0;
    visited[v]=1;
    for(int i:route[v]){
        if (visited[i]==1) continue;
        dfs(i);
        s[v]+=s[i];
    }
    s[v]++;
    return;
}

void testcase(){
    int n ,m ;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        route[a].push_back(b);
        route[b].push_back(a);
    }
    int mx=0;
    for(int i=0;i<n;i++){
        if(visited[i]==1) continue;
        dfs(i);
        mx = max(mx, s[i]);
    }
    cout << mx;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
  //  cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}



Measured memory_bytes: 27800
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll N, K;
int last[200010];
int c[200010];
int A[200010];
vector<int> idx[200010];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        idx[A[i]].push_back(i);
    }

    last[0] = N;
    last[1] = 0;
    int cnt = 1;
    while(last[cnt] != N){
        int s = A[last[cnt] + 1];
        auto it = upper_bound(idx[s].begin(), idx[s].end(), last[cnt] + 1);
        if(it == idx[s].end()){
            cnt++;
            last[cnt] = idx[s][0]; 
        }else{
            last[cnt] = *it;
        }
    }
    K %= cnt;
    stack<int> st;
    for(int i = last[K] + 1; i <= N; i++){
        if(c[A[i]] > 0){
            while(c[A[i]] > 0){
                c[st.top()]--;
                st.pop();
            }
        }else{
            st.push(A[i]);
            c[A[i]]++;
        }
    }
    stack<int> res;
    while(!st.empty()){
        res.push(st.top());
        st.pop();
    }
    while(!res.empty()){
        cout << res.top() << " ";
        res.pop();
    }
    cout << endl;
    return 0;
}

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

/***Crazy Macros***/
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define reu(i,a,b) for (ll i = (a); i <= (b); ++i)
#define red(i,a,b) for (ll i = (a); i >= (b); --i)
typedef int64_t ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
const ll inf = 1e18;
const ll mod = 998244353;

/***Graph Variables***/
vector<vi> adj;
vector<vi> radj;
vi visited;
vi level;

/***Common Functions***/
ll inp() {ll x; cin >> x; return x;}
string inpStr() {string x; cin >> x; return x;}

ll power(ll a, ll b) {
    a %= mod;
    ll res = 1;
    reu(i, 0, log2(b)) {
        if (b & (1<<i)) res = (res*a) % mod;
        a = (a*a) % mod;
    }
    return res;
}
ll gcd(ll a, ll b) {
    while (b > 0) {ll tmp = a%b; a = b; b = tmp;}
    return a;
}
void fast_io() {ios::sync_with_stdio(0); cin.tie(0);}

void file_io(string in, string out) {
    freopen(in.c_str(), "r", stdin);
    freopen(out.c_str(), "w", stdout);
}
/***Main Code***/

int main()
{
    fast_io();
    ll n = inp();
    vi a(n);
    generate(all(a), inp);
    vi Count(n+1);
    fill(all(Count), 0);
    reu(i, 0, n-1) Count[a[i]]++;
    ll sum = 0;
    reu(i, 1, n) {
        ll k = Count[i];
        sum += k*(k-1)/2;
    }
    reu(i, 0, n-1) {
        cout << sum - Count[a[i]] + 1 << "\n";
    }
    return 0;
}



Measured memory_bytes: 5760
#include <math.h>

#include <algorithm>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

int main() {
    int l, r;
    cin >> l >> r;
    int div = 2019;

    if (((r - l) < div)) {
        int ans = 2020;
        repe(i, l, r) {
            repe(j, i + 1, r) {
                ans = min(ans, ((i % div) * (j % div)) % div);
            }
        }
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int a,b;
  cin>>a>>b;
  if(a<=9 && a>=1){
    if(b>=1 && b<=9){
		cout<<a*b;
  	}
    else{
      cout<<"-1";
    }
  }
  else{
    cout<<"-1";
  }
  return 0;
}

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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < m; i++)
    cin >> b[i];
  int len1 = 0, len2 = 0;
  ll sum = 0; 
  for (int i = 0; i < n; i++) {
    if (sum + a[i] > k) 
      break;
    sum += a[i];
    ++len1;
  }
  for (int i = 0; i < m; i++) {
    if (sum + b[i] > k)
      break;
    sum += b[i];
    ++len2;
  }
  int res = len1 + len2;
  for (int i = len1 - 1; i >= 0; i--) {
    sum -= a[i];
    while (len2 < m && sum + b[len2] <= k) {
      sum += b[len2];
      ++len2;
    } 
    res = max(res, i + len2);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 4776
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a = a[0]
c = 0

for i in range(a):
	d = list(map(int,input().split()))
	c = c + (b[0] // d[0])
	if (b[0] % d[0]) > 0 :
		c=c+1
      

b=b[1]

print(c+b)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i= shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int main(){
    int n; cin>>n;
    vi x(n);
    rep(0,i,n) cin>>x[i];
    int mnsum = 0;
    rep(0,i,n){
        mnsum += x[i]*x[i];
    }
    
    int sum;
    int mxx = *std::max_element(x.begin(),x.end());
    rep(1,p,mxx+1){
        sum = 0;
        rep(0,i,n){
            sum += (p-x[i])*(p-x[i]);
        }
        if(sum<mnsum){
            mnsum = sum;
        }
    }
    cout << mnsum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=pow(2,31)-1;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;using namespace std;
void segment_tree(){
	int a,b;
	cin>>a>>b;
	{
		int c=1;
		while(1){
			c*=2;
			if(a<c){a=c;break;}
		}
	}
	vi in(a*2,inf);
	while(b--){
		int c,d,e;
		cin>>c>>d>>e;
		if(c==0){
			d+=a;
			in[d]=e;
			while(d!=1){
				d/=2;
				in[d]=min(in[2*d],in[2*d+1]);
			}
		}else{
			int mi=inf;
			vi q;
			q.pb(0);
			q.pb(a-1);
			q.pb(1);
			while(q.size()){
				int w=q.back();
				q.pop_back();
				int y=q.back();
				q.pop_back();
				int x=q.back();
				q.pop_back();
				if(y<d||e<x)continue;
				if(d<=x&&y<=e){mi=min(in[w],mi);continue;}
				int tmp=(x+y+1)/2;
				q.pb(x);q.pb(tmp-1);q.pb(w*2);
				q.pb(tmp);q.pb(y);q.pb(w*2+1);
			}
			cout<<mi<<endl;
		}
	}
}
void heihou_bunnkatu(){http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A
	int a,b;
	cin>>a>>b;
	vi in(a);
	#define B 200
	vi t(a/B+1);
	while(in.size()%B)in.pb(0);
	while(b--){
		int c,d,e;
		cin>>c>>d>>e;d--;
		if(c==0){
			t[d/B]+=e;
			in[d]+=e;
			//int q=d/B;
			//t[q]=0;
			//rep(i,B)t[q]+=in[q*B+i];//=min(t[q],in[q*B+i]);
		}else{
			int sum=0;
			//e++;
			while(d<e){
				if(d%B==0&&d+B<=e){
					sum+=t[d/B];//mi=min(mi,t[d/B]);
					d+=B-1;
				}else sum+=in[d];//mi=min(mi,in[d]);
				d++;
			}
			cout<<sum<<endl;
		}
	}
}
int main(){
	heihou_bunnkatu();
}

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

const int N = (int) 2e6 + 10 ;
const int inf = (int) 2e9 ;

int cal( int x ) {
    int s = 0 ;
    while( x ) {
        s += x % 10 ;
        x /= 10 ;
    }
    return s ;
}

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    int n ; scanf("%d" , &n ) ;
    int ans = inf ;
    for( int i = 1 ; i < n ; i++ ) {
        ans = min( ans , cal(i) + cal(n - i) ) ;
    }
    cout << ans << endl ;
    return 0 ;
}


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

using namespace std;

int main(){

	int size; cin >> size;
	
	int weight; cin >> weight;

	vector<long>w;
	vector<long>v;
	w.push_back(0);
	v.push_back(0);
	for(int i=0; i<size; i++){
	int a; cin >> a;
	int b; cin >> b;
	w.push_back(a);
	v.push_back(b);
	}
	long dp[size+1][weight+1];
	for(int i=0; i<=size;i++){
		for(int j=0; j<=weight; j++){
			dp[i][j]=0;
		}

	}
	for(int i=0; i<=size; i++){
		
		for(int j=0; j<=weight; j++){
		  if(i==0 ||j==0){
			dp[i][j]=0;
		   }
		   else {
			if(w.at(i) > j){
			 dp[i][j]=dp[i-1][j];
			}
		       
			else{
			if(j-w.at(i) <0){
			 dp[i][j]=max(v.at(i),dp[i-1][j]);
			}
			else{
			dp[i][j]= max(v.at(i)+ dp[i-1][j-w.at(i)] , dp[i-1][j]);
			}
			}
			
			
		   	} 
			
			
		}
	
	}


	cout << dp[size][weight];



}

Measured memory_bytes: 82376
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    string s, t;
    REP(i, n) s += to_string(m);
    REP(i, m) t += to_string(n);
    cout << (s > t ? t : s) << EOL;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i+=2){
		int cnt = 2;
			for(int j = 2; j < i; j++) if(i % j == 0) cnt++;
		if(cnt == 8) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

void fnInput(string& sTarget)
{
  cin >> sTarget;
}

int fnParse(string sTarget)
{
  const vector<string> cnvsWord{"dream", "dreamer", "erase", "eraser"};
  int ixBgn, ixEnd;
  ixBgn = sTarget.size();

  while (ixBgn)
  {
    bool bRslt = false;
    ixEnd = ixBgn;
    for (int i = 0; i < cnvsWord.size(); i++)
    {
      ixBgn = ixEnd - cnvsWord[i].size();
      if (ixBgn < 0)  ixBgn = 0;

      if (sTarget.substr(ixBgn, cnvsWord[i].size()) == cnvsWord[i])
      {
        bRslt = true;
        break;
      }
    }
    if (!bRslt)  return 0;
  }
  return 1;
}

int main()
{
  string sTarget;
  
  fnInput(sTarget);
  if (fnParse(sTarget)) cout << "YES" << endl;
  else                  cout << "NO"  << endl;

  return 0;
}
 

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

int main( void )
{
  string S, T;
  cin >> S;

  reverse( S.begin(), S.end() );

  
  for( int i = 0; i < S.size(); i++ ) {
    T += S.at( i );
    //cout << "T:" << T << endl;
    if( T == "maerd" ) T = "";
    if( T == "remaerd" ) T = "";
    if( T == "esare" ) T = "";
    if( T == "resare" ) T = "";
  }

  if( T == "" )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int a, b; cin >> a >> b;
    cout << (a < 10 && b < 10 ? a * b : -1);
}


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

int main(void){
    int n,k,x,min=1000000001;
    vector<int> tree;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> x;
        tree.push_back(x);
    }
    sort(tree.begin(),tree.end());
//    cout <<"end sort"<< endl;
    for(int i=0;i<tree.size()-k+1;i++){
//        cout << tree[i] << endl;
        if(tree[i+k-1]-tree[i]<min) min=tree[i+k-1]-tree[i];
    }
    cout << min << endl;
    return 0;
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long H;
	scanf("%lld",&H);
	long long N;
	scanf("%lld",&N);
	std::vector<long long> A(N);
	std::vector<long long> B(N);
	for(int i = 0 ; i < N ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
	}

	vector<ll> dp(ceil(2e+4), LONG_LONG_MAX);
	for (ll i = 0; i <= H; ++i)
	{
		dp[i] = static_cast<ll>(ceil(static_cast<double>(i) / A[0])) * B[0];
	}

	for (ll i = 0; i < N; ++i)
	{
		for (ll j = 0; j <= H; ++j)
		{
			dp[j + A[i]] = min(dp[j + A[i]], dp[j] + B[i]);
		}
	}
	cout << *min_element(dp.begin() + H, dp.end()) << endl;

	return 0;
}


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

using namespace std;

int main (){
    //freopen("input.txt", "r", stdin);
    int n;
    cin>>n;
    string str;

    cin>>str;

    int cnt = 1;
    for(int i=0; i<n-1; i++){
        if(str[i] != str[i+1])
            cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
ll n, a, res, ans;
map<ll, ll> mp;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a;
        mp[a]++;
    }
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        res++;
        if (itr->second % 2 == 0) {
            ans++;
        }
    }
    if (ans % 2) cout << res - 1 << endl;
    else cout << res << endl;
}


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

using namespace std;

int t[111111];
int n, c, k;

int main() {
  ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n >> c >> k;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  sort(t+1, t+n+1);
  int l, r = 1, res = 0;
  while (r <= n) {
    l = r;
    while (r <= n and r-l < c and t[r]-t[l] <= k) {
      r++;
    }
    res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
s=input();d=input();n=len(s)
di={"abcdefghijklmnopqrstuvwxyz"[i]:i for i in range(26)}
sl,dl=[set() for _ in range(26)],[set() for _ in range(26)]
for i,(x,y) in enumerate(zip(s,d)):
  sl[di[x]].add(i);dl[di[y]].add(i)
for i in dl:
  if i and i not in sl :print("No");exit() 
print("Yes")


Measured memory_bytes: 47228
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(),x.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T>
void printVec(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << v << ",";
  }
  cout << "]" << endl;
}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int n = 0;
  if(a==b) n++;
  if(b==c) n++;
  if(a==c) n++;

  if(n==1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}


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

const int N = 1e4 + 10;
long long n, q, m, tmp;
long long dp[N][N];
string s, p;
string a1, a2;

int main() 
{
	cin >> q;
	for (int x = 0; x < q; x++) {
	cin >> a1 >> a2;
	if (a1.size() > a2.size())
		s = a1, p = a2;
	else
		p = a1, s = a2;
	n = s.size();
	m = p.size();
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if(s[i] == p[j])
				dp[i + 1][j + 1] = dp[i][j] + 1;
			else
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
//			cout << dp[i + 1][j + 1] << '\n';
		}
	}
	cout << dp[n][m] << '\n';
	}
	return 0;
}


Measured memory_bytes: 14996
s=input()
even=s[1::2]
odd=s[::2]
ez=eo=oz=oo=cnt1=cnt2=0
#print(even,odd)

for i in range(len(odd)):
  if odd[i]!='1':
    cnt1+=1
for i in range(len(even)):
  if even[i]!='0':
    cnt1+=1
for i in range(len(odd)):
  if odd[i]!='0':
    cnt2+=1
for i in range(len(even)):
  if even[i]!='1':
    cnt2+=1
print(min(cnt1,cnt2))

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

int main() {
    ll N; cin >> N;
    vector<pair<ll, ll>> ab(N+1);

    for(ll i=1; i<=N; i++) {
        ll a, b;
        cin >> a >> b;
        ab.at(i).first = b;
        ab.at(i).second = a;
    }

    ll sum = 0;
    sort(ab.begin(), ab.end());
    for(ll i=1; i<=N; i++){
        sum += ab.at(i).second;
        if(sum > ab.at(i).first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
 
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

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

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll N; cin >> N;

  ll mini = INFLL;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i != 0)
      continue;

    ll F = max(to_string(i).size(), to_string(N / i).size());
    mini = min(mini, F);
  }

  cout << mini << endl;
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl v(n), c(n);
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];
  ll ans = 0;
  rep(i, n) ans += max(0LL, v[i] - c[i]);
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    a,b = MII()
    print(a*b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[200005],b[200005];
int c[200005],d[200005];
bool f[35];
int n,ans;
signed main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	for(int i=0;i<=30;i++){
		int t=(1<<i);
		for(int j=0;j<n;j++)
			c[j]=a[j]%(2*t),d[j]=b[j]%(2*t);
		sort(d,d+n);
		for(int j=0;j<n;j++){
			int y=2*t-c[j];
			int x=t-c[j];
			int p1=lower_bound(d,d+n,x)-d;
			int p2=lower_bound(d,d+n,y)-d;
			if(d[p2]>=y)p2--;
			if(p2>=n)p2--;
			if(p2>=p1&&(p2-p1+1)%2==1)f[i]=!f[i];
			y=4*t-c[j];
			x=3*t-c[j];
			p1=lower_bound(d,d+n,x)-d;
			p2=lower_bound(d,d+n,y)-d;
			if(d[p2]>=y)p2--;
			if(p2>=n)p2--;
			if(p2>=p1&&(p2-p1+1)%2==1)f[i]=!f[i];
		}
	}
	for(int i=0;i<=30;i++)
		if(f[i])ans|=(1<<i);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6528
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

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

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;


int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	


	ll cnt = 0;
	while (a[n - 1] >= n) {
		ll c = 0;
		vector<ll> b(n);
		for (int i = 0; i < n; i++) {
			c += a[i] / n;
			b[i] = a[i] / n;
			a[i] %= n;
			cnt += b[i];
		}

		for (int i = 0; i < n; i++) {
			a[i] += c - b[i];
		}

		sort(a.begin(), a.end());
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<cstring>
using namespace std;

int main() {

	int a1, a2, a3, sum;

	cin >> a1 >> a2 >> a3;

	sum = a1 + a2 + a3;

	if(sum >= 22){
	cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
// atcoder/abc165/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int k, a, b;
  while (cin >> k >> a >> b) {
    bool f = false;
    for (int i = a; i <= b; ++i) {
      if (i % k == 0) f = true;
    }
    cout << (f ? "OK" : "NG") << endl;
  }

  return 0;
}


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

int main(){
    string w,t;
    cin >> w;
    int cnt=0;
    while(cin>>t,t!="END_OF_TEXT"){
        for(int i=0; t[i]!='\0'; i++) 
            if(t[i]>='A' && t[i]<='Z')
                t[i]+='a'-'A';
        if(w==t) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3160
#139D

#ここから試験用コード
'''
import itertools

for N in range(1,13):
    l = [i for i in range(1,N+1)]

    ans = 0
    ans_permutation = list()

    for permutation in itertools.permutations(l, N):
        temp_ans = 0
        permutation = [0] + list(permutation)
        for i in range(1,N+1):
            temp_ans += i%permutation[i]

        if ans <= temp_ans:
            if ans < temp_ans:
                ans_permutation = list()
            ans = temp_ans    
            ans_permutation.append(list(permutation)[1:])

    print(N,ans,ans_permutation)
    
#試験用コードの結果
# 1  0 [[1]]
# 2  1 [[2, 1]]
# 3  3 [[1, 3, 2], [2, 3, 1]]
# 4  6 [[2, 3, 4, 1]]
# 5 10 [[1, 3, 4, 5, 2], [2, 1, 4, 5, 3], [2, 3, 4, 5, 1]]
# 6 15 [[2, 3, 4, 5, 6, 1]]
# 7 21 [[1, 3, 2, 5, 6, 7, 4], [1, 3, 4, 5, 6, 7, 2], [2, 3, 1, 5, 6, 7, 4], [2, 3, 4, 5, 6, 7, 1]]
# 8 28 [[2, 1, 4, 5, 6, 7, 8, 3], [2, 3, 4, 5, 6, 7, 8, 1]]
# 9 36 [[1, 3, 4, 5, 6, 7, 8, 9, 2], [2, 3, 4, 1, 6, 7, 8, 9, 5], [2, 3, 4, 5, 6, 7, 8, 9, 1]]
#10 45 [[2, 3, 4, 5, 6, 7, 8, 9, 10, 1]]

#いずれにも最初は2,3...、最後は1となるパターンがある
#上記パターン時は ((N-1)+1)*(N-1)/2 が答え。
'''
N = int(input())
print(N*(N-1)//2)


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

int main()
{
  string s; cin >> s;
  int n = s.length();
  vector<vector<ll>> dp(n+1, vector<ll>(4,0));

  dp[0][0] = 1;
  rep(i, n) {
    if (s[i] == '?') {
      rep(j, 4) dp[i+1][j] = dp[i][j]*3%mod;
      rep(j, 3) (dp[i+1][j+1] += dp[i][j]) %= mod;
    } else {
      int x = s[i]-'A';
      rep(j, 4) dp[i+1][j] = dp[i][j];
      (dp[i+1][x+1] += dp[i][x]) %= mod;
    }
  }
  cout << dp[n][3] << endl;

  return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#include <math.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++)

// 配るDP
int main()
{
    int K, X;
    cin >> K >> X;
    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys

# intの最小値で初期化する
# 最小値
min_num = -sys.maxsize - 1
# 最大差
max_diff = -sys.maxsize - 1
for idx_i in range(int(input())):
    Rt = int(input())
    if(not idx_i):
        min_num = Rt
    else:
        tmp = Rt - min_num
        if(tmp > max_diff):
            max_diff = tmp
        if(Rt < min_num):
            min_num = Rt
print(max_diff)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int l, r, d; cin >> l >> r >> d;
    cout << r / d - (l - 1) / d << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>

int main(void) {
  int c1, c2, c3, count, rest, i;
  int a[11];

  while (scanf("%d %d %d", &c1, &c2, &c3) != EOF) {
    count = 0;
    for (i = 1;i < 11; i++)
      a[i] = 0;
    
    a[c1] = 1;
    a[c2] = 1;
    a[c3] = 1;
    rest = 20 - (c1 + c2);
    for (i = 1; i <= 10; i++) {
      if (i > rest) break;
      if (i != c1 && i != c2 && i != c3)
	count++;
    }
    if (count >= 4)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 576
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    Graph G(N, vector<int>(N, 0));
    rep(i, N){
        int u, k;
        cin >> u >> k;
        u--;
        rep(j, k){
            int v;
            cin >> v;
            v--;
            G[u][v] = 1;
        }
    }

    rep(i, N){
        rep(j, N){
            if(j) cout << ' ';
            cout << G[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

const ll LLMAX = 1e18;

int main() {
    int N; cin >> N;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    // 0 を頭に持ってくるために昇順にソート
    sort(A.begin(), A.end());
    
    ll ans = 1;
    
    rep(i, N) {
        // 0 が存在すれば答え 0 で処理終了
        if (A[i] == 0) {
            ans = 0;
            break;
        }

        // 乗算後 10^18 を超えていたら答え -1 で処理終了
        if (ans > LLMAX / A[i]) {
            ans = -1;
            break;
        }
        
        ans *= A[i];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3964