akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,h,r,l;
ll k;
ll ans;
ll x[1000005], y[1000005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> x[i];
        ll num = x[i];
        for(ll j=2;j*j<=num;j++){
            ll cnt = 0;
            while(num % j == 0){
                num /= j;
                cnt ++;
            }
            if(cnt >= 1){
                y[j] = max(y[j], cnt);
            }
        }
        if(num != 1){
            y[num] = max(y[num], 1ll);
        }
    }
    ll sum = 0;
    for(ll i=0;i<n;i++){
        sum += rui(x[i], mod - 2);
        sum %= mod;
    }
    ll sum2 = 1;
    for(ll i=1;i<=1000000;i++){
        if(y[i] == 0)continue;
        sum2 *= rui(i, y[i]);
        sum2 %= mod;
    }
    ll ans = sum * sum2 % mod;
    p(ans);
    
    return 0;
}
 











Measured memory_bytes: 22400
#include <bits/stdc++.h>
using namespace std;
int h, w, n, num[1100], mp[1100][1100], cnt = 0, now = 0;
int main() {
    cin >> h >> w >> n;
    /*for(int i = 1; i <= n; i++) {
        cin >> num[i];
    }*/
    for(int i = 1; i <= h; i++) {
        int from = (i & 1) ? 1 : w;
        int to = (i & 1) ? w + 1 : 0;
        int delta = (i & 1) ? 1 : -1;
        for(int j = from; j != to; j += delta) {
            if(cnt == 0) {
                now++;
                cin >> cnt;
            }
            mp[i][j] = now;
            cnt--;
        }
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j < w; j++) {
            cout << mp[i][j] << " ";
        }
        cout << mp[i][w] <<endl;
    }
    return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;


int main() {

	int a, b, c, d, e, f;

	cin >> a >> b >> c >> d >> e >> f;

	double condence = -1;
	int sugar = 0;
	int water = 0;

	for (int i = 0; i < (f+(100*a)-1)  / (100*a); i++) {

		for (int j = 0; j < (f + (100 * b) - 1) / (100*b); j++) {
			
			for (int l = 0; l < (f+c-1)/c; l++) {

				for (int m = 0; m < (f+d-1)/d ; m++) {
					
					if ((c * l + m * d + 100 * a * i + 100 * b * j)> f) {
						break;
					}

					double sugar1 = c * l + m * d;
					double total = c * l + m * d + 100 * a * i + 100 * b * j;

					double con = (double)100 * sugar1 / total;
					
					if (e * (100 * a * i + 100 * b * j) >= (c * l + m * d) *100 && condence < con) {
						condence = con;
						water = 100 * a * i + 100 * b * j;
						sugar = c * l + d * m;
					}
				}
			}
			
		}
	}

	cout << water + sugar << " " << sugar << endl;

	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int64_t fabs(int64_t x)
{
    if(x<0)return -x;
    return x;
}
int main()
{
    int64_t N,K;
    cin>>N>>K;
    N -= K*(N/K);
    int64_t a1=N;
    int64_t a2=fabs(N-K);
    while(a1>a2)
    {
        a1=a2;
        a2=fabs(a1-K);
    }
    cout<<a1;
}

Measured memory_bytes: 3568
//                                ** ALLAH **
//                        who is Hussain? -> whoishussain.org

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007;
inline int in(){ int x; scanf("%d",&x); return x; }
const int N = 1e5 + 100;
vector<int> adj[N];
int n, m, pa, qa, ia, mark[N], ret;
void dfs(int v){
        for(int u : adj[v] ){
                if( !mark[u] ) 
                        mark[u] = 3-mark[v],dfs(u);
                else if( mark[u] == mark[v] ) ret = 1;
        }
}
int32_t main(){
        n = in(), m = in();
        for(int i = 0;i < m; i++){
                int u = in()-1, v = in()-1;
                adj[u].pb(v), adj[v].pb(u);
        }

        for(int i = 0;i < n;i ++){
                if( adj[i].empty() ) { ia++; continue; } 
                if( mark[i] ) continue;
                mark[i] = 1, ret = 0;
                dfs(i);
                if( ret ) pa++;
                else qa++;
        }

        cout << 1ll * ia * ia + 1ll * ia * (n-ia) * 2 + 1ll *pa * pa + 1ll*qa * pa * 2 + 2ll * qa * qa << endl; 
}


Measured memory_bytes: 9984
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := input()
	n := len(s)
	numWhite := make([]int, n)
	for i := 0; i < n; i++ {
		if s[i] == 'W' {
			numWhite[i]++
		}
	}
	for i := 1; i < n; i++ {
		numWhite[i] += numWhite[i-1]
	}

	ans := 0
	for i := 0; i < n; i++ {
		if s[i] == 'B' {
			ans += numWhite[n-1] - numWhite[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2944
#include <stdio.h>

void PrimeTable(int);
void PrimeFuctrization2(int);

int PrimeNumber[1001]={};
int Exponent[1001]={};

int main(){
	int N;
	int i;
	long long ans=1;
	
	scanf("%d",&N);
	PrimeTable(N);
	for(i=2;i<=N;i++){
			PrimeFuctrization2(i);
	}
	for(i=0;i<=N;i++){
			ans=((ans*(Exponent[i]+1))%1000000007);
	}
	printf("%lld\n",ans);
	return 0;
}

/*Nまでの素数(Nを含む)をPrimeNumber[]に格納する関数
int PrimeNumber[]={};
を宣言してから使う*/
void PrimeTable(int N){
	int i,j,k=0,flag;
	for(i=2;i<=N;i++){
		flag=0;
		for(j=2;j*j<=i;j++){
			if(!(i%j)){
				flag=1;
				break;
			}
		}
		if(!flag){
			PrimeNumber[k]=i;
			k++;
		}
	}
}

/*整数Nを素因数分解し、PrimeNumber[i]に対応する冪指数をExponent[i]に格納する関数
PrimeTable関数で素数表を生成した上で
int Exponent[]={};
を宣言してから使う*/
void PrimeFuctrization2(int N){
	int i,j;
	for(i=0;N>=PrimeNumber[i];){
		if(!(N%PrimeNumber[i])){
			N/=PrimeNumber[i];
			Exponent[i]++;
		}else{
			i++;
		}
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int s,w;
    cin>>s>>w;
    if(s<=w) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    ll ans = 0;
    rep(i, N) {
        while (true) {
            if (A[i] % 2 == 0) {
                A[i] /= 2;
                ans++;
            }
            else break;
        }
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = input()

S = [int(A[i])-1 for i in range(N)]
Lucas = [0 for i in range(N)]
D = {0: 1}
base, m = 1, N - 1
while m != 0:
  if m % 2 == 1:
    L = [i for i in D]
    for i in L:
      D[i+base] = 1
  m //= 2
  base *= 2
for i in D:
  Lucas[i] = 1
oddness = 0
for i in range(N):
  if S[i] % 2 != 0:
    oddness += Lucas[i]
    oddness %= 2

if oddness == 1:
  print(1)
else:
  if 1 in S:
    print(0)
  else:
    S = [S[i]//2 for i in range(N)]
    oddness = 0
    for i in range(N):
      if S[i] % 2 != 0:
        oddness += Lucas[i]
        oddness %= 2
    if oddness == 1:
      print(2)
    else:
      print(0)

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

int main() {
  int N;
  cin >> N;
  
  
  bool f =false;
  for (int i=1; i<10; i++) {
    for (int j=1; j<10; j++) {
      if (i * j == N) {
        f = true;
        break;
      }
    }
  }
  if (f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    cout << (x ^ 1) << '\n';
}


Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(int(1e6))

n=int(input())
l=[[0,0,0]]
for _ in range(n):
    l.append(list(map(int,input().split())))

memo=[[-1,-1,-1] for _ in range(n+1)]
memo[0][0]=0
memo[0][1]=0
memo[0][2]=0
def dp(i,j):
    if memo[i][j]!=-1:
        return memo[i][j]
    else:
        memo[i][j]=max(dp(i-1,(j+1)%3)+l[i][j],dp(i-1,(j+2)%3)+l[i][j])
        return memo[i][j]
s1=dp(n,0)
s2=dp(n,1)
s3=dp(n,2)
print(max(s1,s2,s3))

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

double area(complex<double> a, complex<double> b, complex<double> c){
  return (conj(b-a)*(c-a)).imag()/2.0;
}

int main(){
  double x1,y1,x2,y2,x3,y3,xp,yp;
  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
    complex<double> v[3];
    complex<double> vp;

    v[0]=complex<double>(x1,y1);
    v[1]=complex<double>(x2,y2);
    v[2]=complex<double>(x3,y3);
    vp  =complex<double>(xp,yp);

    double s[3];
    for(int j=0;j<3;j++) 
      s[j]=area(vp,v[j],v[(j+1)%3]);

    if(s[0]*s[1]>0 && s[1]*s[2]>0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

  return 0;
}

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

#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define i64 long long int
#define MEM(a,x) memset(a,x,sizeof(x))
#define INF 1000000000
#define mod 998244353

using namespace std ;

#define maxn 1000005

int a[maxn] , x[maxn] , mark[maxn] ;

int main()
{
    int i , j , k , l , m , n ;

    scanf("%d",&n) ;

    for(i=1 ; i<=n ; i++) scanf("%d",&x[i]) ;

    for(i=1 ; i<=n ; i++) a[ x[i] ] = i , mark[ x[i] ] = 1 ;

    int last = 1 ;

    for(i=1; i<=n*n ; i++)
    {
        if( a[i]!=0 )
        {
            k = 1 ;
            for(j=last ; k<=a[i]-1 ; j++)
            {
                if( a[j]==0 )
                {
                    a[j] = a[i] ;
                    k++ ;
                }
                if( j>=i )
                {
                    printf("No\n") ;
                    return 0 ;
                }
            }
            last = j ;
        }
    }

//    for(i=1 ; i<=n*n ; i++) printf("%d ",a[i]);
 //   printf("\n") ;

    last = n*n ;

    for(i=n*n ; i>=1 ; i--)
    {
        if(  mark[i] )
        {
            k = a[i]+1 ;
            for(j=last ; k<=n ; j-- )
            {
                if( a[j]==0 )
                {
                    a[j] = a[i] ;
                    k++ ;
                    if( j<=i )
                    {
                        printf("No\n") ;
                        return 0 ;
                    }
                }
            }
            last = j ;
        }
    }

    printf("Yes\n") ;

    for(i=1 ; i<=n*n ; i++) printf("%d ",a[i]) ;

    return 0 ;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long N, long long M, long long X, vector<long long> A) {
    ll min_cost = 1e8;

    ll tmp_cost = 0;
    for (int i = X-1; i <= N; i++) {
        for (int m = 0; m < M; m++) {
            if (i == A[m]-1) tmp_cost++;
        }
    }
    if (min_cost > tmp_cost) min_cost = tmp_cost;

    tmp_cost = 0;
    for (int i = X-1; i >= 0; i--) {
        for (int m = 0; m < M; m++) {
            if (i == A[m]-1) tmp_cost++;
        }
    }
    if (min_cost > tmp_cost) min_cost = tmp_cost;

    cout << min_cost << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  cin >> N;
  long long M;
  cin >> M;
  long long X;
  cin >> X;
  vector<long long> A(M);
  for (int i = 0; i < M; i++) {
    cin >> A[i];
  }
  solve(N, M, X, move(A));
  return 0;
}


Measured memory_bytes: 3612
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		long ans;
      	if(H == 1 || W == 1){
          	ans = 1;
    	}else if(H % 2 == 0 || W % 2 == 0){
			ans = (H * W) / 2;
		}else{
			ans = ((H * W) / 2) + 1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    int X; cin >> X;
    int N = X / 100;
    X %= 100;
    for(int i5 = 0; i5 * 5 <= X; i5++) {
        for(int i4 = 0; i4 * 4 <= X - i5 * 5; i4++) {
            for(int i3 = 0; i3 * 3 <= X - i5*5 - i4*4; i3++) {
                for(int i2 = 0; i2 * 2 <= X - i5*5 - i4*4 - i3*3; i2++) {
                    for(int i1 = 0; i1 * 1 <= X - i5*5 - i4*4 - i3*3 - i2*2; i1++) {
                        if(i5+i4+i3+i2+i1 > N) continue;
                        if(i5*5+i4*4+i3*3+i2*2+i1*1 == X) {
                            cout << 1 << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << 0 << endl;
 
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;
 
const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
 
String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/
 
bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}
 
bool month(int a) {
    return (1<=a&&a<=12) ? true : false;
}
 
string s;
 
void solve()
{
    cin >> s;
    int k, t;
    k = (s[0]-'0')*10 + (s[1]-'0');
    t = (s[2]-'0')*10 + (s[3]-'0');
    //nout(k);nout(t);
    if (month(k)&&month(t)) nout("AMBIGUOUS");
    else if (month(k)) nout("MMYY");
    else if (month(t)) nout("YYMM");
    else nout("NA");
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
const ll mod = 1000000007;

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

    vvi G(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back(b);
    }

    int sv, tv;
    cin >> sv >> tv;
    sv--;  tv--;

    vvi dist(n, vi(3, -1));  // dist[i][j] : 移動距離がmod3でjとなる頂点svから頂点iまでの最短距離
    queue<pii> Q;
    
    dist[sv][0] = 0;
    Q.push(make_pair(sv, 0));
    while(!Q.empty()) {
        int v = Q.front().first;
        int c = Q.front().second;
        Q.pop();
        for(auto u : G[v]) {
            int nc = (c + 1)%3;
            if(dist[u][nc] != -1) {
                continue;
            }
            dist[u][nc] = dist[v][c] + 1;
            Q.push(make_pair(u, nc));
        }
    }
    
    int ans = dist[tv][0];
    if(ans != -1) {
        ans /= 3;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
using lint = long long;
using P = pair<int, int>;

// int A, F, H, I, J, K, L, M, N, S, T, U;
int F, H, I, J, K, L, M, N, S, T, U;
// string S;
int ans = 100000000;
set<P> skills;
vector<int> memo;

int play(int hp) {
	if (memo[hp] != -1) {
		return memo[hp];
	}
	set<int> tmp;
	for (auto skill : skills) {
		if (hp - skill.first <= 0) {
			tmp.insert(skill.second);
		} else {
			tmp.insert(skill.second + play(hp - skill.first));
		}
	}
	return memo[hp] = *tmp.begin();
}

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

	cin >> H >> N;
	rep(i, N) {
		cin >> F >> S;
		skills.insert(make_pair(F, S));
	}
	memo.assign(H + 1, -1);

	cout << play(H) << endl;
	return 0;
}

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

int main(){
	int n, t, ans=0;
	cin >> n >> t;
	int x1=0, x2;

	for(int i=0; i<n; i++){
		cin >> x2;
		if(x2-x1>t) ans += t;
		else ans += x2-x1;
	
		x1 = x2;
	}

	cout << ans+t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  
  ll ans=llINF;
  for(int i=1;i<=sqrt(n);i++){
    if(n%i == 0){
      ans=min(ans,n/i+i);
    }
  }
  cout<<ans-2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll ans=0;
ll n=0,a[200005],b[200005];
int main(){
cin>>n;
for(ll k=1;k<=n;k++)
    cin>>a[k];
    sort(a+1,a+n+1);
b[n]++;
ll j=n;
for(ll k=n-1;k>=1;k--){
    while(b[j]==0LL){
        j--;
    }
    ans+=a[j];
    b[j]--;
    b[k]+=2LL;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 6756
N,M = gets.split.map &:to_i
H = gets.split.map &:to_i
Goods = Array.new(N, true)
M.times {
  a,b = gets.split.map &:to_i
  if H[a-1] >= H[b-1]
    Goods[b-1] = false
  end
  if H[a-1] <= H[b-1]
    Goods[a-1] = false
  end
}
p Goods.count(true)

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



signed main()
{
/*	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];
*/	
//	int ma{};
	int n,d; cin >> n >> d;
	int t = d*2+1;
	//int cnt{};
	int ans{};
	for(int i = 0; t*i < n; ++i){

		ans = i+1;

	}

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

/*	int n,d; cin >> n >> d;
	for(int i = d+1; i < n; ++i){
		if(i-d <= (i-1)*d)
	}*/

	/*	for(int i = 0; i < n; ++i){


		int r = *max_element(a.begin()+i+1, a.end());
		if((a.begin() != a.begin()+i))
		int l = *max_element(a.begin(), a.begin()+i);
		cout << *max_element(a.begin(), a.end()) << endl;
	}*/

	/*	for(int j = 0; j < n; ++j){

	for(int i = 0; i < n; ++i){
		ma = max(ma, a[i]);
	}
	}*/

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#define Max (int)3e3+10
#define MAX_INT (int)1e17+2
#define MOD ((int)1e9+7)
using namespace std;

long long int dp[Max][Max];
int vis[Max][Max];

void init(){
	int i,j;
	for(i=0;i<Max;i++)
		for(j=0;j<Max;j++)
			vis[i][j] = 0;
}

long long int getMax(long long int a,long long int b){
	return a<b?b:a;
}

long long int getMin(long long int a,long long int b){
	return a<b?a:b;
}

long long int solve(int i,int j,long long int a[]){
	if(i+1 == j)
		return getMax(a[i],a[j]);
	else if(i == j)
		return a[i];
	if(vis[i][j] != 0)
		return dp[i][j];

	long long int min1;
	if(i+1 <= j-1)
		min1 = solve(i+1,j-1,a);
	else
		min1 = MAX_INT;
	if(i+2 <= j)
		min1 = getMin(solve(i+2,j,a),min1);
	else{
		if(min1 == MAX_INT)
			min1 = 0;
	}

	long long int min2 = MAX_INT;
	if(i <= j-2)
		min2 = solve(i,j-2,a);
	else
		min2 = 0;
	if(i+1 <= j-1)
		min2 = getMin(solve(i+1,j-1,a),min2);
	else{
		if(min2 == MAX_INT)
			min2 = 0;
	}

	long long int t1 = a[i]+min1;
	long long int t2 = a[j]+min2;
	//printf("LOG %lld %lld\n",t1,t2);
	dp[i][j] = getMax(t1,t2);
	vis[i][j] = 1;
	return dp[i][j];
}

int main(){
	int n,i;
	long long int a[Max],total = 0;
	init();
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		total += a[i];
	}

	long long int p1 = solve(0,n-1,a);
	long long int val = p1-(total-p1);
	printf("%lld\n",val);
}










/*
Atcoder Dp G-Longest Path iterative solution

vector<int>vec[Max];
queue<int>q;

int dp[Max];
int vis[Max];

void init(){
	int i;
	for(i=0;i<Max;i++){
		dp[i] = 0;
		vis[i] = 0;
	}
}

int getMax(int a,int b){
	return (a<b)?b:a;
}

void solve(int x){
	int i,u;
	q.push(x);

	while(!q.empty()){
		u = q.front();
		q.pop();

		if(vis[u])
			continue;
		vis[u] = 1;
		
		for(i=0;i<vec[u].size();i++){
			dp[vec[u][i]] = getMax(dp[vec[u][i]],dp[u]+1);
			q.push(vec[u][i]);
		}
	}

}

int main(){
	int n,m,incoming[Max],x,y,i;
	for(i=0;i<Max;i++)
		incoming[i] = 0;
	
	init();

	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		vec[y].push_back(x);
		incoming[x]++;
	}
	
	for(i=1;i<=n;i++)
		solve(i);
	
	int max = 0;
	for(i=0;i<Max;i++)
		max = getMax(max,dp[i]);
	
	printf("%d\n",max);
	return 0;
}
*/

Measured memory_bytes: 105088
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;



int main() {
  double a, l, x;
  while(cin>>a>>l>>x) {
    double s = (a+l+l)/2;
    double S = sqrt(s*(s-a)*(s-l)*(s-l));
    x = (l+x)/2;
    s = (l+x+x)/2;
    S += 2*sqrt(s*(s-l)*(s-x)*(s-x));
    printf("%.10f\n", S);
  }
}

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

int main(){
	int n,k,z=0,x=0,y=0,a,b;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> k >> a >> b;
		z=k-z;
		x=a-x;
		y=b-y;
		if(i==n-1){
			int aa=abs(x+y);
			if(z==aa || z>aa&&(z-aa)%2==0){
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
			return 0;
		}
		else if(z!=abs(x+y)){
			int aa=abs(x+y);
			if(z>aa&&(z-aa)%2==0){
				z=k;
				x=a;
				y=b;
			}
			else{
				cout << "No" << endl;
				return 0;
			}
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int64_t N,K;
int64_t count[1000000];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N>>K;
	for (int32_t i = 0; i < N; ++i)
	{
		int v, n;
		in >> v >> n;
		count[v] += n;
	}
	int64_t sum = 0;
	for (int32_t i = 0; i < 1000000; ++i)
	{
		sum += count[i];
		if (sum >= K) {
			std::cout << i << std::endl; return 0;
		}
	}


	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;


const int MAX_E = 2000;
const int MAX_V = 1000;
const int64_t INF = 10000000000000000;
// 頂点fromから頂点toへのコストcostの辺
struct edge { int from, to; int64_t cost; };
edge es[MAX_E]; // 辺
int64_t d[MAX_V]; // 最短距離
int V, E; // Vは頂点数、Eは辺数
		  // s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s) {
	for (int i = 0; i < V; i++) d[i] = INF;
	d[s] = 0;
	while (true) {
		bool update = false;
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update) break;
	}
}
// trueなら負の閉路が存在する
bool find_negative_loop() {
	for (int i = 0; i < V; i++) d[i] = 0;
	for (int i = 0; i < V; i++) {
			for (int j = 0; j < E; j++) {
				edge e = es[j];
				if (d[e.to] > d[e.from] + e.cost) {
					d[e.to] = d[e.from] + e.cost;
					// n回目にも更新があるなら負の閉路が存在する
					if (i == V - 1) return true;
				}
			}
	}
	return false;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> V>>E;
	for (int32_t i = 0; i < E; ++i)
	{
		int a, b, c;
		in >> a >> b >> c; --a; --b; c = -c;
		es[i] = edge{ a,b,c };
	}
	if (find_negative_loop()) {
		std::cout << "inf\n"; return 0;
	}
	shortest_path(0);
	std::cout << -d[V - 1] << std::endl;
	return 0;
}
#endif


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 987654321
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

ll n, k, re;

ll s(ll t) { return t * (t + 1) / 2; }

int main() {
	cin >> n >> k;
	for (int i = k; i <= n + 1; i++) {
		re = (re + s(n) - s(n - i) - s(i - 1) + 1) % 1000000007;
	}
	cout << re;
}

Measured memory_bytes: 3632
use std::time::{Duration, Instant};

use proconio::input;
use rand::distributions::{Distribution, Uniform};
use rand_pcg::Mcg128Xsl64;

const V: usize = 26;

struct State {
    cc: Vec<i32>,
    ss: Vec<Vec<i32>>,
    tt: Vec<usize>,
}

impl State {
    fn new(cc: Vec<i32>, ss: Vec<Vec<i32>>, tt: Vec<usize>) -> State {
        State { cc, ss, tt }
    }

    fn find_before(&self, day: usize, target: usize) -> usize {
        for (i, &t) in self.tt[..day].iter().enumerate().rev() {
            if t == target {
                return day - i - 1;
            }
        }
        day
    }

    fn find_after(&self, day: usize, target: usize) -> usize {
        for (i, &t) in self.tt[day + 1..].iter().enumerate() {
            if t == target {
                return i + 1;
            }
        }
        self.tt.len() - day
    }

    fn diff(&self, day: usize, new: usize) -> i32 {
        let now = self.tt[day];
        if new == now {
            return 0;
        }
        let mut diff = self.ss[day][new] - self.ss[day][now];
        diff -= {
            let b = self.find_before(day, now) as i32;
            let a = self.find_after(day, now) as i32;
            self.cc[now] * (a * b + a)
        };
        diff += {
            let b = self.find_before(day, new) as i32;
            let a = self.find_after(day, new) as i32;
            self.cc[new] * (a * b + a)
        };
        diff
    }
}

fn main() {
    let now = Instant::now();

    input! {
        d: usize,
        cc: [i32; V],
        ss: [[i32; V]; d],
    }
    let mut rng = Mcg128Xsl64::new(1);
    let day_samp = Uniform::new(0, d);
    let t_samp = Uniform::new(0, V);

    let tt = {
        let mut tt = Vec::with_capacity(d);
        for _ in 0..d {
            tt.push(t_samp.sample(&mut rng));
        }
        tt
    };
    let mut state = State::new(cc, ss, tt);

    let r_samp = Uniform::new(0.0, 1.0);
    let limit = Duration::from_millis(1950);
    let mut temp = 10000.0;
    while now.elapsed() < limit {
        temp *= 0.98;
        let beta = 1.0 / temp;
        // let mut c = 0;
        for _ in 0..100000 {
            let day = day_samp.sample(&mut rng);
            let target = t_samp.sample(&mut rng);
            let diff = state.diff(day, target);
            if diff >= 0 || r_samp.sample(&mut rng) < (diff as f64 * beta).exp() {
                // if diff < 0 {
                //     c += 1;
                // }
                state.tt[day] = target;
            }
        }
        // eprintln!("{} {} {}", temp, c, (-10.0 * beta).exp());
    }
    for &t in state.tt.iter() {
        println!("{}", t + 1);
    }
}


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

using namespace std;

int main(){
 int N; cin >> N;
  vector<int> a(N+1);
  for(int i = 0; i < N; i++){ cin >> a[i];}
  a[N] = 10001;
  
  int head = 0; int tail = 0;
  
  int cnt = 0;
  
  while( head < N && tail < N){ 
    
    if( a[tail] != a[tail+1] && tail < N){ tail++; head++; continue;}
    
    while( a[tail] == a[tail+1] && tail < N){ tail++;}
    
    cnt += (tail-head+1)/2;
    
    tail++;
    head = tail;
  }
    
  cout << cnt << endl; return 0;
} 

Measured memory_bytes: 384
import math
a,b,x = map(int,input().split())

T = a * b / 2 * a

if T >= x:
    na = 2 * x / b / a
    rad = math.atan(b/na)
    deg = math.degrees(rad)
    print(deg)
else:
    b2 = x * 2 / a / a - b
    rad = math.atan((b-b2)/a)
    deg = math.degrees(rad) 
    print(deg)

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  vi a(3); rep(i,3) cin >> a[i];
  int k; cin >> k;

  sort(rall(a));
  rep(i,k) a[0] *= 2;

  cout << SUM(a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


signed main(){
  int n;cin >> n;
  vector<int> a(n), b(n);
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> b[i];
  int ans = 0;
  rep(i,n)ans += max(a[i]-b[i], 0LL);
  cout << ans << endl;
  return 0;
}






Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
#MOD = 1000000007
MOD = 10000
EPS = 0.000000001
sys.setrecursionlimit(100000)


SIZE = 13
POW = [1] * (SIZE)
for i in range(1,SIZE):
    POW[i] = POW[i-1]*2

while True:
    M,W = map(int,input().split())
    if M == 0 and W == 0:
        break

    table = []

    table.append(list(map(int,input().split()))) #Mの読み込み
    table.append(list(map(int,input().split()))) #Wの読み込み

    small = None
    large = None
    if M < W:
        small = 0
        large = 1
    else:
        small = 1
        large = 0

    len_small = len(table[small])
    len_large = len(table[large])

    dp = [[-BIG_NUM]*POW[len_large] for _ in range(len_small+1)] #要素数が大きい方を常態化する(少ない方は全部使うため)

    ans = 0
    dp[0][0] = 0 #dp[少ない方のインデックス(1開始)][多い方の使用状態] = 最大値

    for i in range(len_small): #今回マッチさせる微生物のループ(少ない側)
        for state in range(0,POW[len_large]): #既に使った微生物のループ(大きい側)
            if dp[i][state] == -BIG_NUM:
                continue
            for k in range(len_large):
                if state & POW[k] != 0:
                    continue
                next_state = state+POW[k]
                next_value = dp[i][state]+abs(table[small][i]-table[large][k])* \
                    (abs(table[small][i]-table[large][k])-30)*(abs(table[small][i]-table[large][k])-30)

                dp[i+1][next_state] = max(dp[i+1][next_state],next_value)
                ans = max(ans,next_value)

    print("%d"%(ans))


Measured memory_bytes: 14700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// 最初の単語を受け取る
		Scanner sc = new Scanner(System.in);
		StringBuilder str = new StringBuilder(sc.nextLine());

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

			String order = sc.next();

			// 変数aは第1引数で使用する
			int a = sc.nextInt();
			// 変数bは第2引数で使用する
			int b = sc.nextInt()+1;

			if (order.equals("print")) {

				System.out.println(str.substring(a, b));	// substring()メソッド。a文字目からb文字目の手前まで引き抜く

			} else if(order.equals("reverse")) {

				str.replace(a, b, new StringBuilder(str.substring(a, b)).reverse().toString());

			} else {
				String s = sc.next();
				str.replace(a, b, s);
			}
		}

	}

}



Measured memory_bytes: 28840
N,M=map(int,input().split())
ac=[0]*(10**5+1)
temp=[0]*(10**5+1)
wa=[0]*(10**5+1)
for i in range(M):
  p,S=input().split()
  if ac[int(p)]==0:
    if S=="WA":
      temp[int(p)]+=1
    else:
      ac[int(p)]=1
for i in range(len(ac)):
  wa[i]=ac[i]*temp[i]
print(sum(ac),sum(wa))


Measured memory_bytes: 11120
#include <iostream>

using namespace std;

int main(void)
{
    int m, f, r;

    cin >> m >> f >> r;
    while ((m != -1) || (f != -1) || (r != -1))
    {
        int sum = m + f;
        if ((m == -1) && (f != -1))
            cout << 'F' << endl;
        else if ((m != -1) && (f == -1))
            cout << 'F' << endl;
        else if (sum >= 80)
            cout << 'A' << endl;
        else if ((sum >= 65) && (sum < 80))
            cout << 'B' << endl;
        else if ((sum >= 50) && (sum < 65))
            cout << 'C' << endl;
        else if ((sum >= 30) && (sum < 50))
        {
            if (r >= 50)
                cout << 'C' << endl;
            else
                cout << 'D' << endl;
        }
        else
            cout << 'F' << endl;
        cin >> m >> f >> r;
    }
}


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

int main() {
  int d;
  cin >> d;
  vector<long long> c(26);
  for(int i = 0; i < 26; i++) cin >> c.at(i);
  vector<vector<long long>> s(d, vector<long long> (26));
  for(int i = 0; i < d; i++){
    for(int j = 0; j < 26; j++) cin >> s.at(i).at(j);
  }
  
  vector<int> ans(d), last(26);
  long long score = 0;
  for(int i = 0; i < d; i++){
    int a;
    cin >> a;
    a--;
    last.at(a) = i+1;
    score += s.at(i).at(a);
    for(int j = 0; j < 26; j++){
      score -= c.at(j) * (i + 1 - last.at(j));
    }
    cout << score << endl;
  }
}

Measured memory_bytes: 3720
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  set<int>::reverse_iterator rit; for(rit=s.rbegin();rit!=s.rend();rit++)
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db eps=1e-6;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e6+8;
using namespace std;

ll t,n,m,cnt=0,ans=0;

int main(){
    scanf("%lld%lld%lld",&t,&n,&m);
    cnt=t/(n+m);
    t%=(n+m);
    if(t>n) t=n;
    printf("%lld\n",cnt*n+t);
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> vec(n);
  int count=0;
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    count+=vec.at(i);
  }
  int sum=0;
  int answer=5000000;
  for(int i=0;i<n;i++){
    sum+=vec.at(i);
    if(abs(sum-(count-sum))<answer){
      answer=abs(sum-(count-sum));
    }
  }
  cout<<answer<<endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
//#define int __int128
//#define ll __int128
typedef pair<int, int   > pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
//typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;
#define mp(a, b) make_pair(a, b)

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}

ostream & operator << (ostream &out, pii a) {
    cout << a.first << " " << a.second ;
    return out;
}

void smain();

signed main() {

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {

    ll a, b;
    cin >> a >> b;
    if (a <= 0) {
        if (b >= 0) {
            cout << "Zero";
        } else {
            int len = b - a + 1;
            if (len & 1) {
                cout << "Negative";
            } else {
                cout << "Positive";
            }
        }
    } else {
        cout << "Positive";
    }
}

Measured memory_bytes: 256