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

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q=0;
        Data []A = new Data[n];
        Data []B = new Data[n];
        for(int i = 0; i < n; i++) {
            String s = sc.next();
            int t = sc.nextInt();
            A[i] = new Data(s.charAt(0), t);
            B[i] = new Data(s.charAt(0), t);
        }
		quickSort(A, 0, n-1);
		mergeSort(B, n, 0, n);
		
        int stable = 1;
        for(int i = 0; i < n; i++) {
            if(A[i].getSuit() != B[i].getSuit()) {
                stable = 0;
                break;
            }
        }
        if(stable == 1) {
            System.out.println("Stable");
        }else {
            System.out.println("Not stable");
        }
        for(int i = 0; i < n; i++) {
            System.out.println(A[i].getSuit() + " " + A[i].getValue());
        }
	}
	
	static void quickSort(Data[] A, int p, int r){
		int q;
		if (p < r){
			q = partition(A, p, r);
			quickSort(A, p, q - 1);
			quickSort(A, q + 1, r);
		}
	}
	
	static int partition(Data[] A, int p, int r){
		Data x;
		Data tmp;
		x = A[r];
		int i = p-1;
		for (int j = p; j<r; j++){
			if(A[j].getValue() <= x.getValue()){
				i++;
				tmp = A[i];
				A[i] = A[j];
				A[j] = tmp;
			}
		}
		tmp = A[i+1];
		A[i+1] = A[r];
		A[r] = tmp;
		return i+1;
	}
	
	public static void merge(Data[] A, int n, int left, int mid, int right){
		int n1 = mid - left;
		int n2 = right - mid;
		Data[] L = new Data[n1+1];
		Data[] R = new Data[n2+1];
		for(int i=0; i<n1; i++){
			L[i] = A[left+i];
		}
		for(int i=0; i<n2; i++){
			R[i] = A[mid + i];
		}
		L[n1] = new Data(' ', 2000000000);
		R[n2] = new Data(' ', 2000000000);
		int i = 0;
		int j = 0;
		for(int k=left; k<right; k++){
			if(L[i].getValue() <= R[j].getValue()){
				A[k] = L[i];
				i = i + 1;
			}else {
				A[k] = R[j];
				j = j + 1;
			}
		}
	}
	
	public static void mergeSort(Data[] A, int n,int left, int right){
		if (left+1 < right){
			int mid = (left + right)/2;
			mergeSort(A, n,left, mid);
			mergeSort(A, n, mid, right);
			merge(A, n, left, mid, right);
		}
	}
}

class Data {
    private char suit;
    private int value;
    public Data(char suit, int value) {
        this.suit = suit;
        this.value = value;
    }
    public char getSuit() {
        return suit;
    }
    public int getValue() {
        return value;
    }
    public void setSuit(char suit) {
        this.suit = suit;
    }
    public void setValue(int value) {
        this.value = value;
    }
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){for(int i=0;i<n;i++) cin>>f[i];}

template<typename T,typename U>
void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];}
template<typename T,typename U>
void Printarray2(T f,U n){for(int i=0;i<n;i++) cout<<f[i]<<endl;}
template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}
template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){flag ? cout<<A<<endl : cout<<B<<endl;}
void flag2func(bool flag){flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;}
void flag3func(bool flag){flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;cin>>n;
  vector<int> x(n);rep(i,n)cin>>x[i];
  int ans=1e6,sum;
  rep2(i,1,100){
    sum=0;
    rep(j,n)sum+=pow(x[j]-i,2);
    if(ans>sum)ans=sum;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
class Integer
  def divisor
    res = []
    1.upto((self**0.5)) do |i|
      if self % i == 0
        res.push i
        res.push self / i if i != self / i
      end
    end
    res.sort
  end
end

def answer_if_valid(x, a, d)
  b = a - d
  if x == a ** 5 - b ** 5
    puts "#{a} #{b}"
    exit
  end
end

x = gets.to_s.to_i

r = x % 5

divisors = x.divisor.select{|t| r == t % 5}

divisors.each do |d|
  
  left = (( x / d - d ** 4 ) / 5).abs
  
  if left == 0
    answer_if_valid(x,0,d)
    (d ** 3).abs.divisor.each do |a|
      answer_if_valid(x, a, d)
      answer_if_valid(x,-a, d)
    end
  end
  
  left.divisor.each do |a|
    answer_if_valid(x,  a, d)
    answer_if_valid(x, -a, d)
  end
end

Measured memory_bytes: 14752
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL D, A;

pair<LL, LL> P[200011];

LL F[200011];

void MAIN() {
    scanf("%d%lld%lld", &N, &D, &A);
    REP (i, N) scanf("%lld%lld", &P[i].first, &P[i].second);
    sort(P, P+N);
    
    LL ans = 0;
    REP (i, N) {
	if (F[i] < P[i].second) {
	    LL rest = P[i].second - F[i];
	    LL t = (rest + A - 1) / A;
	    F[i] += A*t;
	    ans += t;
	    LL right = P[i].first + D + D;
	    int k = upper_bound(P, P+N, make_pair(right, 1LL<<60)) - P;
	    F[k] -= A*t;
	}
	F[i+1] += F[i];
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
using ll  = long long;
#define int ll

const int N = 2e5 + 100;

int hi[N];
set<int> g[N];

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::sync_with_stdio(0), cin.tie(0);
	
	int h, w, n, ans, x, y;
	cin >> h >> w >> n;
	fill_n(hi, N, -N);
	hi[1] = 1;
	while (n--) {
		cin >> x >> y;
		g[y].insert(x);
	}
	for (int i = 2; i <= w; ++i) {
		hi[i] = hi[i - 1] + 1;
		while (g[i].count(hi[i])) {
			++hi[i];
		}
	}
	ans = h;
	for (int i = 1; i <= w; ++i) {
		assert(!g[i].count(hi[i]));
		auto it = g[i].upper_bound(hi[i]);
		if (it != g[i].end()) {
			ans = min(ans, *it - 1);
		}
	}
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

typedef pair<int,int> P;

int main() {
    int n;
    cin >> n;
    vector<int> G[n];
    for (int i=0; i<n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int c[n];
    for (auto &ci:c) cin >> ci;
    sort(c, c+n);
    int len[n], d[n], m=0, ucnt=0;
    bool used[10000] = {0};
    for (int i=0; i<n; i++) len[i] = (int)G[i].size();
    while (ucnt < n) {
        // for (auto l : len) cerr << l << '\n';
        for (int i = 0; i < n; i++) {
            if (used[i] || len[i] > 1) continue;
            if (!used[i] && len[i] == 0) {
                d[i] = c[ucnt];
                ucnt = n; break;
            }
            d[i] = c[ucnt];
            m += c[ucnt];
            ucnt++;
            len[i] = 0;
            for (auto g:G[i])
                if (!used[g])
                    len[g]--;
            used[i] = true;
        }
    }
    cout << m << '\n';
    for (int i=0; i<n; i++) 
        cout << d[i] << (i==n-1 ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int x, y, z;

signed main() {
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
v=[]
w=[]
for _ in range(N):
    ww,vv=map(int,input().split())
    v.append(vv)
    w.append(ww)

dp=[[0 for _ in range(W)] for _ in range(N)]

for h in range(W):
    if h+1>=w[0]:
        dp[0][h]=v[0]

for i in range(1,N):
    for j in range(W):
        if j+1>w[i]:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[-1][-1])

Measured memory_bytes: 171784
// g++ -std=gnu++1y -O2 main.cpp

#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1e9;
const long long LINF = 1e18;

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

	for (int i = 0; i < N; i++)
	{
		int Ai;
		cin >> Ai;

		if ((Ai % 2) == 0) {
			if (!(((Ai % 3) == 0) || ((Ai % 5) == 0))) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}

	cout << "APPROVED" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define sit set<int>::iterator
#define ll long long
using namespace std;
const int N=1e6+6,P=1e9+7;
int f[N],iv[N];
int C(int n,int m){ return (ll)f[n]*iv[m]%P*iv[n-m]%P; }
int path(int n,int m){ return C((n-1)+(m-1),n-1); }
int main(){
    int n,m,a,b; cin>>n>>m>>a>>b;
    int t=2*max(n,m); f[0]=1,iv[0]=iv[1]=1;
    rep(i,1,t) f[i]=(ll)f[i-1]*i%P;
    rep(i,2,t) iv[i]=(ll)iv[P%i]*(P-P/i)%P;
    rep(i,2,t) iv[i]=(ll)iv[i-1]*iv[i]%P;
    int s=(ll)path(n-a+1,b)*path(a,m-b+1)%P;
    rep(i,n-a+2,n)
        s=(s+(ll)path(i,b-1)*path(n-i+1,m-b+1))%P;
    cout<<(path(n,m)-s+P)%P<<endl;
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
    string a, b;
    cin >> a >> b;

    int num = stoi(a + b);

    for (int i = sqrt(num) - 1; i <= sqrt(num); i++)
    {
        if (num == i * i)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

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

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

  vector<int> a;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  std::sort(a.begin(), a.end());

  int m = 1e9;
  for (int i = 0; i < N - K + 1; i++) {
    m = min(m, a[i+K-1] - a[i]);
  }
  cout << m << endl;
}


Measured memory_bytes: 892
import itertools
N,M,R=map(int,input().split())
rlist=list(map(int,input().split()))

def warshall_floyd(d):
  #d[i][j]: iからjへの最短距離
  for k in range(N+1):
    for i in range(N+1):
      for j in range(N+1):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

# vlistに点のリスト、dist[vi][vj]に辺(vi,vj)のコストを入れて呼び出す
dist=[[float("inf")]*(N+1) for i in range(N+1)] 
for i in range(M):
  a,b,c=map(int,input().split())
  dist[a][b]=c
  dist[b][a]=c
for i in range(N+1):
  dist[i][i]=0

dist=warshall_floyd(dist)
#print(dist)

max_answer=float("inf")
for perm in itertools.permutations(rlist):
  #print(perm)
  answer=0
  for i in range(R-1):
    answer+=dist[perm[i]][perm[i+1]]
  
  max_answer=min(max_answer,answer)  
  
print(max_answer)

Measured memory_bytes: 58712
///https://atcoder.jp/contests/abc154/tasks/abc154_c

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

int a[200001];
int ans[200001] = {0};

int main()
{
    int t;

    scanf("%d",&t);
    for(int i=0; i<t; i++)
    {
        long long x;
        scanf("%d",&a[i]);
    }
    sort(a, a+t);


    for(int i=0;i<t-1; i++)
    {
        if(a[i]==a[i+1])
        {printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define N 100005
using namespace std;
int n,tot,a[N],b[N],c[N],e[N],d[N*3];
ll ans,v[N*3];
void add(int x,ll y){
	for (;x<=tot;x+=x&(-x)) v[x]+=y;
}
ll ask(int x){
	ll s=0;
	for (;x;x-=x&(-x)) s+=v[x];
	return s; 
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),d[++tot]=a[i];
	for (int i=1;i<=n;i++)
		scanf("%d",&b[i]),d[++tot]=b[i];
	for (int i=1;i<=n;i++)
		scanf("%d",&c[i]),d[++tot]=c[i];
	sort(d+1,d+tot+1);
	for (int i=1;i<=n;i++){
		a[i]=lower_bound(d+1,d+tot+1,a[i])-d;
		add(a[i],1);
	}
	for (int i=1;i<=n;i++){
		b[i]=lower_bound(d+1,d+tot+1,b[i])-d;
		e[i]=ask(b[i]-1);
	}
	memset(v,0,sizeof(v));
	for (int i=1;i<=n;i++)
		add(b[i],e[i]);
	for (int i=1;i<=n;i++){
		c[i]=lower_bound(d+1,d+tot+1,c[i])-d;
		ans+=ask(c[i]-1);
	}
	printf("%lld",ans);
}

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

using namespace std;

const int MAXN = 2e5 + 20, MAXM = 124, SZ = 26, L = 32;
const long long inf = 1e9 + 100, mod = 1e9 + 7;
mt19937 rnd;

void solve() {
    int n, r;
    cin >> n >> r;
    if (n >= 10)
        cout << r << '\n';
    else
        cout << r + 100 * (10 - n) << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

using namespace std;

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    vector<bool> dp(k + 1);
    for (int stone = 0; stone <= k; ++stone) {
        for (int x : a) {
            if (stone >= x and dp[stone - x] == false) {
                dp[stone] = true;
            }
        }
    }
    cout << (dp[k] == true ? "First" : "Second");
}


Measured memory_bytes: 256
N=[(list(map(int,input().split(' ')))) for i in range(3)]

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (N[0][0]-a1==N[1][0]-a2==N[2][0]-a3
                    and  N[0][1] -a1==N[1][1]-a2==N[2][1]-a3
                    and N[0][2] -a1 == N[1][2]-a2 ==N[2][2] -a3):
                print('Yes')
                exit()
print('No')

Measured memory_bytes: 3064
#include <cstdlib>
#include <iostream>
#include <vector>
typedef long long LL;

int main() {
  int n, k; std::cin >> n >> k;
  std::vector<LL> h(n), cost(n);
  for (int i = 0; i < n; ++i) std::cin >> h[i];

  cost[n-1] = 0;

  for (int i = n-2; i >= 0; --i) {
    int jmax = std::min(i+k, n-1);
    cost[i] = std::abs(h[i]-h[i+1]) + cost[i+1];
    for (int j = i+2; j <= jmax; ++j) {
      cost[i] = std::min(cost[i], std::abs(h[i]-h[j]) + cost[j]);
    }
  }

  std::cout << cost[0] << std::endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

int main(){

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

    cout << min(b/a, c) << endl;

    return 0;
}

Measured memory_bytes: 256
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end


n,k = gsmi #10**5
as = gsmi

l = 0
(k...n).each do |r|
  puts (as[l]<as[r]) ? 'Yes' : 'No'
  l = l+1
end


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

const int MAX_N=100009;
int par[MAX_N];
int myrank[MAX_N];
int size[MAX_N];

void init(int n){
  for(int i=1;i<=n;i++){par[i]=i; myrank[i]=0; size[i]=1;}
}

int find(int x){
  if(par[x]==x){return x;}
  else{return par[x]=find(par[x]);}
}

void unite(int x, int y){
  x=find(x); y=find(y);
  if(x==y){return;}
  if(myrank[x]<myrank[y]){par[x]=y; size[y]+=size[x];}
  else{par[y]=x; size[x]+=size[y];}
  if(myrank[x]==myrank[y]){myrank[x]++;}
}

bool same(int x, int y){return find(x)==find(y);}

int main(){
  long long N,M;
  cin >> N >> M;
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++)cin >> A[i] >> B[i];
  init(100009);
  vector<long long> q;
  long long ans=N*(N-1)/2;
  q.push_back(ans);
  for(int i=M-1;i>0;i--){
    if(same(A[i],B[i])){q.push_back(ans);}
    else{
      int a=A[i],b=B[i]; A[i]=max(a,b); B[i]=min(a,b);
      ans-=(size[find(A[i])])*(size[find(B[i])]);
      unite(A[i],B[i]);
      q.push_back(ans);
    }
  }
  for(int i=q.size()-1;i>=0;i--){cout << q[i] << endl;}
}

Measured memory_bytes: 4212
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void solve() {
		int n=s.nextInt();
		for(int i=1;i<=n;i++) {
			if((int)(i*1.08) == n) {
				out.println(i);
				return;
			}
		}
		out.println(":(");
	}

	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	
}


Measured memory_bytes: 21204
n = int(input())
alist = [int(i) for i in input().split()]

def calc_gcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def listup_gcm(xlist):
    list_gcm = []
    prev = None
    for a in xlist:
        if prev is None:
            list_gcm.append(a)
            prev = a
            continue
        gcm = calc_gcm(prev, a)
        list_gcm.append(gcm)
        prev = gcm
    return list_gcm


left_gcm = listup_gcm(alist)
alist.reverse()
right_gcm = listup_gcm(alist)
right_gcm.reverse()


maxgcm = 0
for i in range(n):
    if i == 0:
        maxgcm = max(maxgcm, right_gcm[1])
    elif i == n - 1:
        maxgcm = max(maxgcm, left_gcm[n-2])
    else:
        maxgcm = max(maxgcm, calc_gcm(left_gcm[i-1], right_gcm[i+1]))

print(maxgcm)


Measured memory_bytes: 65516
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5596
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  string c;
  cin>>c;
  ll ans=0;
  for(int i=0;i<1000;i++){
    vc s(3);
    if(i<10){
      s[0]='0';
      s[1]='0';
      s[2]=(char)(i+'0');
    }
    else if(i<100){
      s[0]='0';
      s[1]=(char)((i/10)%10+'0');
      s[2]=(char)(i%10+'0');
    }
    else{
      s[0]=(char)(i/100+'0');
      s[1]=(char)((i/10)%10+'0');
      s[2]=(char)(i%10+'0');
    }
    ll cu=0;
    for(int j=0;j<sz(c);j++){
      if(c[j]==s[cu]){
        cu++;
      }
      if(cu==3){
        ans++;
        break;
      }
    }
  }
  COUT(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1000000000;
const int SEG_SIZE = 1<<17;

int Seg_tree[SEG_SIZE*2];


void add(int i,int x)
{
   int now = i+SEG_SIZE;
   while(1)
   {
      Seg_tree[now] += x;
      now/=2;
      if(now==0)break;
   }
}

int getSum(int l,int r)
{
   int res = 0;
   l+=SEG_SIZE;
   r+=SEG_SIZE;
   while(1)
   {
      
      if(l%2==1)
      {
         res+=Seg_tree[l];
         l++;
      }
      
      if(r%2==1)
      {
         res+=Seg_tree[r-1];
         r--;
      }
      if(l==r)break;
      l/=2;
      r/=2;
   }
   return res;
}


int main()
{
   int n,q;
   cin >> n >> q;
   rep(i,q)
   {
      int com,x,y;
      cin >> com >> x >> y;
      x--;
      if(com==0)
      {
         add(x,y);
      }else
      {
         cout<<getSum(x,y)<<endl;
      }
      
   }
   return 0;
}


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

clock_t present = clock();
void complexiti(){
	present = clock() - present;
	cerr << "TIME : " << float(present)/CLOCKS_PER_SEC << '\n';
}

//~ axbdeab
//~ abx

void solver(){
	//~ type your code here
	ll ans = 0 , times = 0;
	string s , t;
	cin >> s >> t;
	vector<int> v[30] , cnt1(30,0) , cnt2(30,0);
	for(int i = 0 ; s[i] ; ++i){
		v[s[i]-'a'].push_back(i);
		cnt1[s[i]-'a']++;
	}
	for(int i = 0 ; t[i] ; ++i){
		cnt2[t[i]-'a']++;
	}
	for(int i = 0 ; i < 26 ; ++i){
		if(cnt2[i] != 0 && cnt1[i] == 0){
			cout << -1 << endl;
			return;
		}
	}
	ll pos = -1;
	for(int i = 0 ; t[i] ; ++i){
		pos = upper_bound(v[t[i]-'a'].begin() , v[t[i]-'a'].end() , pos) - v[t[i]-'a'].begin();
		if(pos == (ll)v[t[i]-'a'].size()){
			times = times + 1;
			pos = v[t[i]-'a'][0];
		}else{
			pos = v[t[i]-'a'][pos];
		}
	}
	ll sz = s.size();
	ans = sz * times + pos + 1LL;
	cout << ans << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int queries = 1;
	//~ cin >> queries;
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	complexiti();
	return 0;
}


Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
ll wt[110000];
ll val[110000];

ll knapsack(ll w, ll n){
	ll knsck[n+1][w+1];

	for(ll i=0; i<=n; i++){
		for(ll j=0; j<=w; j++){
			if(i==0||j==0){
				knsck[i][j] = 0;
			}
			else if(wt[i-1]<= j){
				knsck[i][j] = max(knsck[i-1][j], knsck[i-1][j-wt[i-1]]+val[i-1]);
			}
			else{
				knsck[i][j]=knsck[i-1][j];
			}
		}
	}
	return knsck[n][w];
}



int main(){
	/*#ifndef ONLINE_JUDGE
	freopen("/home/shubham/Desktop/codes/input.txt", "r", stdin);
	freopen("/home/shubham/Desktop/codes/output.txt", "w", stdout);
	#endif*/


	ll n, w;
	cin>>n>>w;
	for(ll i=0; i<n; i++){
		cin>>wt[i]>>val[i];
	}
	cout<<knapsack(w, n);

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int N;
  string S1, S2;
  const ll MOD = 1e9 + 7;

  cin >> N;
  cin >> S1;
  cin >> S2;

  ll comb = 1;
  int type;
  int index = 0;

  if (S1[0] == S2[0]) {
    comb = 3;
    type = 1;
    index++;
  } else {
    comb = 6;
    type = 2;
    index += 2;
  }

  while (index < N) {
    if (S1[index] == S2[index]) {
      if (type == 1) {
        comb *= 2;
      }
      type = 1;
      index++;
    } else {
      if (type == 1) {
        comb *= 2;
      } else {
        comb *= 3;
      }
      type = 2;
      index += 2;
    }

    comb %= MOD;
  }

  cout << comb << endl;

  return 0;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int X;
    cin >> X;
   
    vi B(max(X+1, 106), 0);
    for(int i = 100; i <= 105; i++){
        B[i] = 1;
    }
    for(int i = 0; i < X+1; i++){
        for(int j = 100; j <= 105; j++){
            if(i-j>0 && B[i-j] == 1){
                B[i] = 1;
            }
        }
    }
    cout << B[X] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll h,a;
  cin>>h>>a;
  ll n=h%a;
  ll p=h/a;
  if(n==0){
    cout<<p<<endl;
  }
  else{
    cout<<p+1<<endl;
  }
  return 0;
}


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

using namespace std;

int main(){
  int N,K; cin>>N>>K;
  vector<int> l(N);
  for(int i=0;i<N;i++) cin>>l[i];

  sort(l.begin(),l.end(),greater<int>());
  
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=l[i];
  }

  cout<<ans<<endl;

  return 0;
}



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

using namespace std;

const int MAXN = 2e5 + 5;
const int oo = 1e9 + 7;

int n, a[MAXN], b[MAXN];

struct BIT {
private:
    vector<int> t;
public:
    BIT(int n) {t.assign(n+1, 0);}
    void update(int p, int x) {
        for(int i = p; i < t.size(); i += i&(-i))
            t[i] += x;
    }
    int query(int p) {
        int res = 0;
        for(int i = p; i > 0; i -= i&(-i))
            res += t[i];
        return res;
    }
};

long long C2(long long n) {return n*(n+1)/2;}

bool Check(int mid) {
    vector<int> d(n+1);
    for(int i = 1; i <= n; ++i)
        d[i] = d[i-1] + ((a[i] >= b[mid]) ? 1 : -1);

    BIT t(2*n);
    long long cnt = 0;
    for(int i = 1; i <= n; ++i) {
        t.update(d[i-1] + n, 1);
        cnt += t.query(d[i] + n);
    }

    return (2*cnt >= C2(n));
}

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

    for(int i = 1; i <= n; ++i)
        b[i] = a[i];
    sort(b+1, b+n+1);

    int lo = 1, hi = n, res = 0;
    while (lo <= hi) {
        int mid = (lo+hi)/2;
        if (Check(mid)) {
            res = mid;
            lo = mid+1;
        } else hi = mid-1;
    }

    printf("%d\n", b[res]);

    return 0;
}

Measured memory_bytes: 5652
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

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


int main(){
	double eps = 10e-9;
	
	int N;
	scanf("%d",&N);

	for(int n=0;n<N;n++){
		string str;
		cin >> str;
		vector<int> tmp;
		for(int i=0;i<str.size();i++){
			tmp.push_back(str[i]-'0');
		}
		sort(tmp.begin(),tmp.end());

		int a=0;
		for(int i=tmp.size()-1;i>=0;i--){
			a += tmp[i] * (pow(10,(double)i) + eps);
		}

		int b=0;
		sort(tmp.begin(),tmp.end(),greater<int>());
		for(int i=tmp.size()-1;i>=0;i--){
			b += tmp[i] * (pow(10,(double)i) + eps);
		}
		cout << a-b << endl;
	}

}

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

const int MX = 200005, MOD = 1E9 + 7;

int b, w;
long long fct[MX], inv[MX], inv_fct[MX], pw[MX];
long long wl[MX], bla[MX], bln[MX];

void init()
{
    fct[0] = inv_fct[0] = 1;
    inv[1] = fct[1] = inv_fct[1] = 1;
    for (int i = 2; i < MX; i++)
    {
        inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
        fct[i] = fct[i - 1] * i % MOD;
        inv_fct[i] = inv_fct[i - 1] * inv[i] % MOD;
    }
    pw[0] = 1;
    for (int i = 1; i < MX; i++)
        pw[i] = pw[i - 1] * inv[2] % MOD;
}

long long C(int n, int k)
{
    if (n < 0 || k < 0 || n < k)
        return 0;
    else
        return fct[n] * inv_fct[k] % MOD * inv_fct[n - k] % MOD;
}

void make_sum()
{
    for (int i = 1; i <= w; i++)
    {
        long long cur = pw[b + w - i] * C(b + w - i - 2, b - 2) % MOD;
        wl[i] = (wl[i - 1] + cur) % MOD;
    }
    for (int i = 1; i <= b; i++)
    {
        long long cur = pw[b + w - i] * C(b + w - i - 2, w - 1) % MOD;
        bln[i] = (bln[i - 1] + cur) % MOD;
    }
    for (int i = b; i >= 1; i--)
    {
        long long cur = pw[b + w - i] * C(b + w - i - 1, w - 1) % MOD;
        bla[i] = (bla[i + 1] + cur) % MOD;
    }
}

int main()
{
    init();
    scanf("%d%d", &b, &w);
    make_sum();
    for (int i = 1; i <= b + w; i++)
    {
        int pos = b + w + 1 - i;
        long long cur = 0;
        // white last
        if (pos >= 2)
        {
            (cur += wl[min(w, pos - 2)]) %= MOD;
            // the transition black block
            if (pos <= w + 1)
                (cur += pw[i] * C(i - 1, b - 1)) %= MOD;
        }

        // black last, and among the last blacks
        if (pos <= b)
            (cur += bla[pos]) %= MOD;

        // black last, but not among the last blacks
        if (pos >= 2)
            (cur += bln[min(b, pos - 2)]) %= MOD;

        printf("%lld\n", cur);
    }
}


Measured memory_bytes: 12416
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//高さと幅
	static int H, W;
	//ジャグ配列（迷路を保存）
	static char[][] grid;
	//最短距離を格納
	static int[,] minDist;
	//次の地点を格納するキュー
	static Queue<int> nextI, nextJ;

	//幅優先探索
	static void BFS(int i, int j){
		//既に辿り着いている場合、終了
		if(minDist[H-1,W-1] != -1){
			return;
		}
		else{
			//この地点から進める場所を格納
			//1.上
			if(i > 0){
			if(grid[i-1][j] == '.' && minDist[i-1, j] == -1){
					nextI.Enqueue(i-1);
					nextJ.Enqueue(j);
					//最短距離を更新
					minDist[i-1,j] = minDist[i,j] + 1;
				}
			}
			//2.下
			if(i < H-1){
				if(grid[i+1][j] == '.' && minDist[i+1, j] == -1){
					nextI.Enqueue(i+1);
					nextJ.Enqueue(j);
					//最短距離を更新
					minDist[i+1,j] = minDist[i,j] + 1;
				}
			}
			//3.右
			if(j < W-1){
				if(grid[i][j+1] == '.' && minDist[i, j+1] == -1){
					nextI.Enqueue(i);
					nextJ.Enqueue(j+1);
					//最短距離を更新
					minDist[i,j+1] = minDist[i,j] + 1;
				}
			}
			//4.下
			if(j > 0){
				if(grid[i][j-1] == '.' && minDist[i, j-1] == -1){
					nextI.Enqueue(i);
					nextJ.Enqueue(j-1);
					//最短距離を更新
					minDist[i,j-1] = minDist[i,j] + 1;
				}
			}

			//次の地点へ進む（進める場合）
			if(nextI.Count() > 0){
				int ni = nextI.Dequeue();
				int nj = nextJ.Dequeue();
				BFS(ni, nj);
			}
		}
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');
		H = int.Parse(S[0]);
		W = int.Parse(S[1]);

		//初期化
		grid = new char[H][];
		minDist = new int[H,W];
		nextI = new Queue<int>();
		nextJ = new Queue<int>();

		//グリッドを読み込む
		for(int i=0; i<H; i++){
				string line = Console.ReadLine();
				grid[i] = new char[W];
				grid[i] = line.ToCharArray();
		}

		//白マスの合計値を取得するとともに、最短距離を初期化
		int whiteSum = 0;
		for(int i=0; i<H; i++){
			for(int j=0; j<W; j++){
				minDist[i,j] = -1;
				if(grid[i][j] == '.'){
					whiteSum ++;
				}
			}
		}

		//探索
		minDist[0,0] = 0;
		BFS(0,0);
		int ans = -1;

		//最短経路が見つかった場合
		if(minDist[H-1,W-1] != -1){
			ans = (whiteSum - minDist[H-1,W-1] - 1);
		}

		Console.WriteLine(ans);
	}
}



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

deque<int> working;
int num = 0;
int main(){
	int n;
	char read;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf(" %c", &read);
		if(read == '(') read = 1;
		else if(read == ')') read = -1;
		//else continue;
		if(num == 0 && read == -1){
			working.push_front(1);
			num++;
		}
		working.push_back(read);
		num += read;
	}
	for(int i = 0; i < num; ++i) working.push_back(-1);
	for(auto k: working){
		cout << (k == 1 ? "(": ")");
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int main() {
  int n;
  cin >> n;
  string com, s;
  map<string, bool> dict;
  rep(i, n) {
    cin >> com >> s;
    if (com == "insert") {
      dict[s] = true;
    }
    else {
      if (dict[s]) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }

  
  return 0;
}


Measured memory_bytes: 52472
#include<stdio.h>
#include<string.h>
int main(void)
{
  int n,k,q;
  int a[100000];
  int point[1000000]={0};
  
  scanf("%d %d %d",&n,&k,&q);
  for(int i=0;i<q;i++){
    scanf("%d",&a[i]);
    point[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    if(k+point[i]-q>0){
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  }
  return 0;
}
  

Measured memory_bytes: 4864
#include<iostream>

using namespace std;

int main()
{
 while(1){
 char str[150];
 int pointA=0;
 int pointB=0;
 int j=1;
 cin>>str;
 if(str[0]=='0'){break;}
 while(str[j]!='\0'){
	if(str[j]=='A'){
		pointA++;}
	if(str[j]=='B'){
		pointB++;}
	j++;
 }
 if(pointA>pointB)pointA++;
 if(pointA<pointB)pointB++;
 cout<<pointA<<' '<<pointB<<'\n';
 }
return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;

int A[30], B[30];
signed main() {
	int N; cin >> N;
	REP(i, N)cin >> A[i];
	REP(i, N)cin >> B[i];
	int ans = 0;
	REP(i, N) {
		if (A[i] > B[i])ans += A[i] - B[i];
	}
	print(ans);
}


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

/* constant */

#define MAX_N   (300000)
#define MAX_Q   (100000)

/* global variables */

static int cards[MAX_N + 1];
static int cmap[MAX_N * 2 + 1];

/* subroutines */

int comp(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

/* main */

int main(int argc, char **argv) {
  int c0, c1, i, j, max_c, max_qi, max_rem, n, prev, q, qi, qn, rem;

  scanf("%d%d", &n, &qn);

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

  qsort(cards, n, sizeof(int), comp);

  c0 = 0;
  for (i = 0; i < n; i++) {
    c1 = cards[i];
    for (j = c0; j < c1; j++) cmap[j] = c0;
    c0 = c1;
  }
  max_c = cmap[c0] = c0;

  for (i = 0; i < qn; i++) {
    scanf("%d", &q);

    max_qi = (max_c / q + 1) * q;
    for (j = max_c; j <= max_qi; j++)
      cmap[j] = max_c;

    max_rem = 0;

    for (qi = q - 1; qi <= max_qi; qi += q) {
      rem = cmap[qi] % q;
      if (max_rem < rem) {
        max_rem = rem;
        if (max_rem == q - 1) break;
      }
    }

    printf("%d\n", max_rem);
  }

  return 0;
}

Measured memory_bytes: 3372
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;

int main()
{

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

  double ans = 0;

  repd(i, 1, N + 1)
  {
    int p = i;
    int cnt = 0;
    while (true)
    {
      if (p >= K)
        break;
      p *= 2;
      cnt++;
    }
    double a = (double)1 / (double)N;
    double b = pow((double)1 / 2, cnt);
    // cout << a << " " << b << " " << cnt << endl;
    ans += a * b;
  }

  printf("%.12f", ans);
}

Measured memory_bytes: 256
n,k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
used = [0]*n
for i in range(1,2*n):
    now = a[now-1]
    if (used[now-1]==0):
        used[now-1]=i
    else:
        bef = used[now-1]
        loop = i-used[now-1]
        break
if (bef>=k):
    print(used.index(k)+1)
else:
    over = (k-bef)%loop
    #print(bef,over,loop,used)
    print(used.index(bef+over)+1)
        
    

Measured memory_bytes: 32288
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007

bool isContain(vector<int> &vec, int num) {
    if (find(vec.begin(), vec.end(), num) != vec.end()) {
        // findがvecのlast_iterを返さなければtrue
        return true;
    }
    return false;
}

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

    // input
    int A, B, C;
    cin >> A >> B >> C;
    
    // calc
    if (A <= C && C <= B) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    static long mod=1000000007;
    static long[][] dp;
    public static void main(String[] args)throws Exception{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String[] s=br.readLine().split(" ");
        int n=Integer.parseInt(s[0].trim());
        int m=Integer.parseInt(s[1].trim());
        char[][] a=new char[n][m];
        for(int i=0;i<n;i++){
            String s1=br.readLine().trim();
            for(int j=0;j<m;j++){
                a[i][j]=s1.charAt(j);
            }
        }
        dp=new long[n][m];
        for(int i=0;i<n;i++){
            Arrays.fill(dp[i],-1);
        }
        System.out.println(grid(a,n-1,m-1));






    }

    public static long grid(char[][] a,int i,int j){
        if(dp[i][j]!=-1){
            return dp[i][j];
        }

        if(i==0 && j==0){
            dp[i][j]=1;
            return 1;
        }
        long res=0;
        if(i-1>=0 && a[i-1][j]!='#'){
            res=(grid(a,i-1,j)%mod);
        }
        long res2=0;
        if(j-1>=0 && a[i][j-1]!='#'){
            res2=(grid(a,i,j-1)%mod);
        }
        long r=((res%mod)+(res2%mod))%mod;
        dp[i][j]=r;
        return r;
    }






}


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

int main() {
 int x,y;
  for(int i=0; i < 3000; i++){
    cin >> x >>y;
    if(x==0 && y==0){
      break;
    }
    if(x > y){
      swap(x,y);
      
    }
    
    cout << x << ' ' << y << endl;
  }
  
    
  
  
}



Measured memory_bytes: 2960
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
c=0
for i in range(N-2):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if(L[i]!=L[j]):
                if(L[j]!=L[k]):
                    if(L[i]+L[j]>L[k]):
                        c+=1
print(c)

Measured memory_bytes: 9180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			x = in.readLine();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		String[] ab = x.split(" ");

		int a = Integer.parseInt(ab[0]);
		int b = Integer.parseInt(ab[1]);
		
		System.out.println((a * b) + " " + ((a + b) * 2));
	}
}

Measured memory_bytes: 24204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int s;
	std::cin >> s;
	std::cout << s/3600<<":";
	s%=3600;
	std::cout << s/60<<":";
	s%=60;
	std::cout << s << std::endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define prev prev1
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R) {
	int val=rng() % R;
      assert(val>=0);
      return val;
}
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD1;


int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int x,y;
           cin>>x>>y;
           int div1=4*x-y;
           int div2=y-2*x;
           if(div1<0 || div2<0 || div1%2==1 || div2%2==1)cout<<"No"<<endl;
           else
           cout<<"Yes"<<endl;
      }      
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int a,b;
int main()
{
	cin>>a>>b;
	if(a>0)cout<<"Positive"<<endl;
	else if(a<=0&&b>=0) cout<<"Zero"<<endl;
	else
	{
		if((b-a)%2==0)cout<<"Negative"<<endl;
		else cout<<"Positive"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256