akhauriyash/Code-Regression huggingface dataset:
#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 int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

template<typename T> T GCD(T x, T y){
    if(x < y)swap(x, y);
    if(y == 0)return x;
    return GCD(x % y, y);
}

int main()
{
  int n; cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  for(int i = 0; i < n-1; i++){
    v[i+1] = GCD(v[i], v[i+1]);
  }
  cout << v[n-1] << endl;
  system("pause");
}


Measured memory_bytes: 1272
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

/// [..), 1-origin
struct BITree(alias _fun, alias init, T)
if (is(typeof(init) : T))
{
    import std.functional : binaryFun;
    alias fun = binaryFun!_fun;

    ///
    this(size_t n, T[] ts) {
        this.n = n;
        this.tree.length = n+1;
        foreach (ref e; this.tree) e = init;
        foreach (i, t; ts) this.put(i+1, t);
    }

    /// This method does not replace the element but applies old one and new one to the `fun`.
    void put(size_t i, T e) {
        while (i <= this.n) {
            this.tree[i] = fun(this.tree[i], e);
            i += i & -i;
        }
    }

    ///
    T query(size_t i) {
        auto r = init;
        while (i > 0) {
            r = fun(r, this.tree[i]);
            i -= i & -i;
        }
        return r;
    }

private:
    size_t n;
    T[] tree;
}

/// The `init` value is used for the `query` method as first value,
/// so you can not use this argument to initialise the tree.
/// In other words, this is identity element.
BITree!(fun, init, T) bitree(alias fun, alias init, T)(size_t n, T[] ts = [])
{
    return BITree!(fun, init, T)(n, ts);
}

///
BITree!(fun, init, T) bitree(alias fun, alias init, T)(T[] ts)
{
    return BITree!(fun, init, T)(ts.length, ts);
}

void main()
{
    auto N = readln.chomp.to!int;
    int[] as, bs;
    foreach (a; readln.split.to!(int[])) {
        as ~= a;
        bs ~= a;
    }
    sort(bs);
    int[int] cs;
    foreach (i, b; bs) cs[b] = i.to!int+1;

    long r;
    auto bit = bitree!("a + b", 0, int)(N);
    foreach (i, a; as) {
        auto b = cs[a];
        r += i.to!int - bit.query(b);
        bit.put(b, 1);
    }
    writeln(r);
}


Measured memory_bytes: 26288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, m;
    int[] ts, ps, xs;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        ts = new int[n];
        for (int i = 0; i < n; i++) {
            ts[i] = sc.nextInt();
        }
        m = sc.nextInt();
        ps = new int[m];
        xs = new int[m];
        for (int i = 0; i < m; i++) {
            ps[i] = sc.nextInt() - 1;
            xs[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        for (int i = 0; i < m; i++) {
            int sum = 0;
            for (int j = 0; j < n; j++) {
                if (j == ps[i]) {
                    sum += xs[i];
                } else {
                    sum += ts[j];
                }
            }
            System.out.println(sum);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


Measured memory_bytes: 21204
a,b,c = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
count = 0
for i in range(a-1):
    if (ar[i+1] - ar[i]) * b <= c:
        count += (ar[i+1] - ar[i]) * b
    else:
        count += c
print(count)


Measured memory_bytes: 14224
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 100005
using namespace std;

struct node
{
	ll x,y,val;
}tr[maxn];
ll t,n,r,c;
ll fa[maxn],del[maxn],mn1[maxn],mn2[maxn];//del[i]指i到父节点的差值
const ll oo=2e16;

bool cmp(node a,node b)
{
	if(a.y!=b.y)
	return a.y<b.y;
	else return a.x<b.x;
}//以y轴为第一关键字从小到大排序

ll find(ll a)
{
	if(fa[a]==a)
	return a;
	ll fax=find(fa[a]);
	del[a]+=del[fa[a]];//合并差值
	return fa[a]=fax;
}//找父亲

ll unionn(ll a,ll b,ll v)
{
	ll fax=find(a),fay=find(b);
	if(fax!=fay)
	{
		del[fax]=v+del[b]-del[a];//推导的性质
		fa[fax]=fay;//合并并查集
		return 1;
	}//不在同一个集合内
	else
	{
		if(del[a]!=del[b]+v)return 0;
		else return 1;
	}//在同一个集合内
}//并查集合并

int main()
{
	for(int i=1;i<=100000;++i)
	mn1[i]=mn2[i]=oo;
	ll flag=1;
	scanf("%lld%lld%lld",&r,&c,&n);
	for(ll i=1;i<=r;++i)
	{
		fa[i]=i;
		del[i]=0;
	}//初始化并查集
	for(ll i=1;i<=n;++i)
	{
		ll x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);
		tr[i].x=x;
		tr[i].y=y;
		tr[i].val=z;
		if(z<0)flag=0;
	}
	if(!flag)
	{
		printf("No\n");
		return 0;
	}
	if(r==1)
	{
		printf("Yes\n");
		return 0;
	}//特判行为1
	sort(tr+1,tr+1+n,cmp);//初始化排序
	for(ll i=1;i<n;++i)
	{
		if(tr[i].y==tr[i+1].y)
		{
			if(!unionn(tr[i].x,tr[i+1].x,tr[i+1].val-tr[i].val))//顺便结合两行
			flag=0;//与所得结论矛盾
		}
	}//判断是否矛盾
	if(!flag)
	{
		printf("No\n");
		return 0;
	}
	for(ll i=1;i<=n;++i)
	{
		ll fax=find(tr[i].x);
		mn1[fax]=min(mn1[fax],tr[i].val+del[tr[i].x]);
	}//求父节点行上一点的最小值
	for(ll i=1;i<=r;++i)
	{
		ll fax=find(i);
		mn2[fax]=min(mn2[fax],-del[i]);
	}//求某一行的父节点可能的最小值
	for(ll i=1;i<=r;++i)
	{
		if(fa[i]==i&&mn1[i]+mn2[i]<0)
		{
			flag=0;
			break;
		}
	}
	if(!flag)
	printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    std::vector<std::vector<lint>>a(m);
    for(lint i=0;i<n;i++){
        lint k;std::cin>>k;
        while(k--){
            lint x;std::cin>>x;
            a.at(x-1).push_back(i);
        }
    }
    std::vector<std::vector<lint>>g(n);
    for(auto&&b:a){
        lint sz=b.size();
        for(lint i=0;i<sz-1;i++){
            g.at(b.at(i)).push_back(b.at(i+1));
            g.at(b.at(i+1)).push_back(b.at(i));
        }
    }
    std::deque<lint>que;
    std::vector<lint>ckd(n);
    ckd.at(0)=true;
    que.push_back(0);
    while(!que.empty()){
        lint x=que.front();que.pop_front();
        for(lint y:g.at(x)){
            if(ckd.at(y))continue;
            que.push_back(y);
            ckd.at(y)=true;
        }
    }
    std::cout<<(std::all_of(ckd.begin(),ckd.end(),[](lint x){return x;})
        ?"YES":"NO")<<'\n';
}


Measured memory_bytes: 9588
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;
ll a[100001];
ll sum[100001];

map<ll, ll> mp;

int main(int argc, char const* argv[])
{
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++)cin >> a[i];
	sum[0] = a[0];
	for(int i = 1; i < n; i++)sum[i] = (sum[i-1] + a[i]) % m;
	for(int i = 0; i < n; i++)mp[sum[i] % m]++;
	ll res = mp[0];
	ll tmp = sum[0] % m;
	for(int i = 0; i < n; i++){
			mp[sum[i] % m]--;
			res += mp[tmp % m];
			tmp = sum[i+1] % m;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 5760
n = int(input())
aa = list(map(int, input().split()))

c = [0]*(10**6+1)

for a in aa:
    c[a] += 1

d = [False]*(10**6+1)

count = 0

for i in range(1, 10**6+1):
    if not c[i]:
        continue
    if d[i]:
        continue
    if c[i] == 1:
        count += 1
    for j in range(i, 10**6+1, i):
        d[j] = True

print(count)

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

int main(){
    int N;
    long long count = 0;
    std::cin >> N;
    vector<long long> L(N);

    for(int i = 0; i < N; i++){
        std::cin >> L[i];
    }

    for(int i = 0; i < N - 2; i++){
        for(int j = i + 1; j < N -1; j++){
            for(int k = j + 1; k < N; k++){
                if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]){
                    if(L[i]+L[j]>L[k] && L[j]+L[k]>L[i] && L[k]+L[i]>L[j]){
                        count++;
                        // std::cout << L[i] << " " << L[j] << " " << L[k] << "\n";
                    }
                }
            }
        }
    }
    std::cout << count;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int M=3e3+4;
double dp[M][M],p[M],ans;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>p[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(j==0)
			dp[i][j]=dp[i-1][j]*(1-p[i]);
			else
			dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
		}
	}
	for(int i=0;i<=n;i++)
	{
		if(i>(n-i))
		ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(10);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 68992
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,l;
  cin>>n>>l;
  string s;
  vector<string>v;
  for(int i=0;i<n;i++)
  {
    cin>>s;
    v.push_back(s);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<v.size();i++)
  {
    cout<<v[i];
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> adj_list;
vector<int> dp;
int func(int node)
{
  if(adj_list[node].size() == 0 )  return 0;
  if(dp[node] != -1) return dp[node];
  int count = 0;
  for(int i =0; i<adj_list[node].size(); i++){
    count = max(count,1+func(adj_list[node][i]));
  }
  return dp[node] = count;
}
int main(){
    
    cin>>n>>m;
    adj_list.clear();
    adj_list.resize(n+1);
    dp.clear();
    dp.resize(n+1, -1);
    while(m--){
        int n1, n2;
        cin>>n1>>n2;
        adj_list[n1].push_back(n2);
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(dp[i] == -1)
        {
            ans = max(ans,func(i));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 2000003;
const int MOD = 1000000007;
  map<int,int> mp[3];
        signed main() {
    cout<<fixed<<setprecision(15);
    int n;
    cin>>n;
    int a,xa=0,c=0,k=(MOD+1)/2;
  
    for(int i=0;i<n;i++){
            cin>>a;
            xa^=a;
            if(xa!=0){
                     if(mp[0].find(xa)==mp[0].end()){
                    mp[0][xa]=1;
                    mp[1][xa]=0;
                    mp[2][xa]=0;
                }
                mp[0][xa]=(mp[0][xa]+mp[1][xa]*(c-mp[2][xa]))%MOD;
                mp[1][xa]=(mp[1][xa]+mp[0][xa])%MOD;
                mp[2][xa]=c;
            }else{
                    c++;
                    k=(2*k)%MOD;
            }
           
    }
    int ans=0;
    if(xa==0){
            for(auto i=mp[1].begin();i!=mp[1].end();i++){
                ans=(ans+(i->second))%MOD;
               // cerr<<i->first<<' '<<i->second<<endl;
            }
            ans=(ans+k)%MOD;
    }else{
            ans=mp[0][xa];
    }
    cout<<ans;

    
      }

        


Measured memory_bytes: 54144
from collections import Counter
N, M = map(int, input().split())
A = list(map(int, input().split()))

cntA = Counter(A)
for _ in range(M):
    B, C = map(int, input().split())
    cntA[C] += B

ans = 0
for val, cnt in sorted(cntA.items(), reverse=True):
    ans += val * min(N, cnt)
    N -= cnt
    if N <= 0:
        break
print(ans)

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int s[1<<18];

int main(){
    scanf("%d",&n);
    const int m = 1<<n;
    REP(i,m)scanf("%d",s+i);
    // sort(s,s+m);
    // reverse(s,s+m);
    multiset<int> S;
    REP(i,m)S.insert(-s[i]);
    vector<int> cur, nxt;
    cur.push_back(*S.begin()); S.erase(S.begin());
    REP(i,n){
        nxt = cur;
        for(int x : cur){
            auto it = S.upper_bound(x);
            if(it == S.end()){
                puts("No");
                return 0;
            }
            nxt.push_back(*it);
            S.erase(it);
        }
        cur = nxt;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 15348
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

const double pi = 3.14159265358979323846;
signed main()
{   
    int r;
    cin>>r;
    cout<<fixed;
    cout<<setprecision(20);
    cout<<(2*pi*r)<<endl;
	return 0;
}

Measured memory_bytes: 3788
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        int K = sc.nextInt();
        if(2*K>=(B-A+1)){
            for(long i=A;i<=B;i++){
                System.out.println(i);
            }
        }
        else{
            for(long i=A;i<A+K;i++){
                System.out.println(i);
            }
            for(long i=B-K+1;i<=B;i++){
                System.out.println(i);
            }
        }
        //System.out.println(ans);
    }
}

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

using namespace std;

int main()
{
    char str1[10],str2[10];
    scanf(" %s %s",str1,str2);
    bool flag=true;
    for(int i=0;i<3;i++)
    {
        if(str2[3-i-1]!=str1[i])
            flag=false;
    }
    if(flag)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
program main
    implicit none
    integer(8):: h,w,k
    integer(8):: i,j
    integer(8), allocatable:: c(:,:), now(:)
    integer(8), parameter:: inf = 1001001001
    character(1), allocatable:: s(:,:)
    read*, h,w,k
 
    allocate(s(w,h))

    block
        character(:), allocatable:: input_s
        allocate(character(w)::input_s)

        do i=1,h
            read*, input_s(:)
            do j=1,w
                s(j,i) = input_s(j:j)
            end do
        end do
    end block


    block
        integer(8):: div, g, ints, num
        integer(8):: ans = inf
        integer(8), allocatable:: id(:)
        logical:: emp, ok

        allocate(id(h))
        do div=1, lshift(1, h-1)
            g = 1

            do i=1, h
                id(i) = g
                if (and(rshift(div-1,i-1), 1) == 1) g=g+1
            end do

            allocate(c(w, maxval(id)))
            c(:,:) = 0

            do i=1,h
                do j=1,w
                    ints = ichar(s(j,i))-48
                    ! read(s(j,i),*) ints
                    c(j,id(i))=c(j,id(i))+ints
                end do 
            end do

            ok=.true.
            do i=1,g
                do j=1,w
                    if(c(j,i) > k) ok = .false.
                end do
            end do

            if (.not. ok) then
                deallocate(c)
                cycle
            end if

            allocate(now(g+1))
            num = g-1
            now(:) = 0
            do j=1,w
                if (.not. add(j,g)) then
                    num=num+1
                    now(:)=0
                    emp = add(j,g)
                end if
            end do 

            ans = min(ans,num)
            deallocate(c)
            deallocate(now)
        end do

        print*, ans
    end block

contains
function add(j,g) result(ok)
    integer(8):: i,j,g
    logical:: ok

    do i=1,g
        now(i)=now(i)+c(j,i)
    end do

    ok=.true.
    do i=1,g+1
        if (now(i) > k) ok=.false.
    end do
end function

end program main

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=1e9+7;
const long double PI = acos(0);
template <class T>void UNIQUE(vector<T> &x){
	sort(all(x));
	x.erase(unique(all(x)), x.end());
}

// }}} End Header
int main() {
	int n, ans = 0;
	cin >> n;
	vector<ll> l(n);
	map<ll, ll> dict;
	rep(i,n){
		cin >> l[i];
		dict[l[i]]++;
	}
	UNIQUE(l);
	if(l.size()<3){
		cout << 0 << endl;
		return 0;
	}
	rep(i,l.size()-2){
		loop(j, i+1, l.size()-1){
			loop(k, j+1, l.size()){
				if(l[i]+l[j] > l[k]){
					//cout << l[i] << l[j] << l[k] << endl;
					ans+=(dict[l[i]]*dict[l[j]]*dict[l[k]]);
				}		
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S, T;
  cin >> S >> T;
  ll ans = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] != T[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(void){
    int n,m;
    cin >> n >> m;
    int gyoretsu[100][100] = {{}};
    int retsubekutoru[100] = {};
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> gyoretsu[i][j];
        }
    }
    for (int k = 0; k < m; k++){
        cin >> retsubekutoru[k];
    }
    
    for (int a = 0; a < n; a++){
        int x = 0;
        for (int b = 0; b < m; b++){
            x += gyoretsu[a][b] * retsubekutoru[b];
        }
        cout << x << endl; 
    }
    return 0;
}



Measured memory_bytes: 3144
#include<stdio.h>
int main(void)
{
	int n;
	int x;
	int suu[5],s[16],keta[4];
	int i,j,k;
	
	scanf("%d",&n);
	suu[0]=suu[1]=suu[2]=suu[3]=1000000;
	for(i=0;i<n;i++)	{
		scanf("%d",&suu[4]);
		for(j=3;j>=0;j--)	{
			if(suu[j]>suu[j+1])	{
				x=suu[j];
				suu[j]=suu[j+1];
				suu[j+1]=x;
			}
			else {
				break;
			}
		}
	}
//	printf("%d %d %d %d\n",suu[0],suu[1],suu[2],suu[3]);
	for(j=0;j<4;j++)	{
		x=10;
		for(i=1;i<=7;i++)	{
			if(suu[j]<x)	{
				keta[j]=x;
				break;
			}
			else {
				x=x*10;
			}
		}
	}
//	printf("keta=%d %d %d %d\n",keta[0],keta[1],keta[2],keta[3]);
	
	
	k=0;
	for(i=0;i<4;i++)	{
		for(j=0;j<4;j++)	{
			if(i!=j)	{
				s[k]=suu[i]*keta[j]+suu[j];
//				printf("s=%d\n",s[k]);
				k++;
			}
		}
	}
	for(i=0;i<k-1;i++)	{
		for(j=i+1;j<k;j++)	{
			if(s[i]>s[j])	{
				x=s[i];
				s[i]=s[j];
				s[j]=x;
			}
		}
	}
	printf("%d\n",s[2]);
	return 0;
}


Measured memory_bytes: 592
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var x = next(), y = next(), a = next(), b = next(), c = next();
  var p = nexts(a).sort((a,b)=> b-a);
  var q = nexts(b).sort((a,b)=> b-a);
  var r = nexts(c).sort((a,b)=> b-a);
  var z = [];
  for(var i = 0; i < x; i++)z.push(p[i]);
  for(var i = 0; i < y; i++)z.push(q[i]);
  z.sort((a,b)=> b-a);
  var id = x+y-1;
  for(var i = 0; i < c && id >= 0; i++, id--){
    if(z[id] < r[i])z[id] = r[i];
    else break;
  }
  return z.reduce((a,b)=>a+b);
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vvec<int> g(n);
    REP(i, n) {
        int u, k;
        cin >> u >> k;
        u--;
        REP(i, k) {
            int v;
            cin >> v;
            v--;
            g[u].push_back(v);
        }
    }
    vec<ll> d(n, INF);
    queue<ll> que;
    que.push(0);
    d[0] = 0;
    while(que.size()) {
        int v = que.front();
        que.pop();
        for(auto to : g[v]) {
            if(d[to] != INF)
                continue;
            d[to] = d[v] + 1;
            que.push(to);
        }
    }

    REP(i, n) {
        if(d[i] == INF)
            cout << i + 1 << " " << -1 << en;
        else
            cout << i + 1 << " " << d[i] << en;
    }
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector< vector <int> >vee;
typedef vector<pair<int,int> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const int N=1e5+5;
bool f;
ll dp[10000][10000],n,m;
char grid[1005][1005];
ll solve(int i=0,int j=0)
{
    if(i==n-1&&j==m-1)return 1;
    if(i<0||i==n||j<0||j==m||grid[i][j]=='#')return 0;
    ll &ret=dp[i][j];
    if(~ret) return ret;
    return ret=( solve(i+1,j)+solve(i,j+1) )%((int)1e9+7);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
     memset(dp,-1,sizeof dp);
     cin>>n>>m;
     rep(i,n)
      rep(j,m)
       cin>>grid[i][j];
     cout<<solve();
go;
}


Measured memory_bytes: 782592
#include <bits/stdc++.h>
#define     ll                      long long
#define     boost                   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     all(v)                  v.begin(),v.end()
#define     revall(v)               v.rbegin(),v.rend()
#define     pb                      push_back
#define     eb                      emplace_back
#define     sl(x)                   scanf("%lld", &x)
#define     sll(x, y)               scanf("%lld %lld", &x, &y)
#define     slll(x, y, z)           scanf("%lld %lld %lld", &x, &y, &z)
#define     read                    freopen("input.txt","r",stdin)
#define     write                   freopen("output.txt","w",stdout)
#define     println()               cout << endl
#define     gcd(a,b)                __gcd(a,b)
#define     lcm(a,b)                (a)*(b)/gcd(a,b)
#define     printl(x)               printf("%lld\n")
#define     printll(x,y)            printf("%lld %lld\n")
#define     printlll(x,y,z)         printf("%lld %lld %lld\n")
#define     vll                     vector<ll>
using namespace std;
int main(){

        ll cnt =0,ans=0;
        vector<ll>v;
        string s;
        cin>>s;
        for(ll i=0; i<s.size(); i++)
        {
            if(s[i] == 'R') cnt++;
            else
            {
                if(cnt!=0) v.pb(cnt);
                cnt=0;
            }
        }
        if(cnt) v.pb(cnt);
        sort(revall(v));
        if(v.size()>0) cout<<v[0]<<endl;
        else cout<<0<<endl;
}


Measured memory_bytes: 3596
# -*- coding: utf-8 -*-
from fractions import gcd

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    res = 0
    i = 1
    for a in A:
        if i == a:
            i += 1
        else:
            res += 1

    if res == N:
        res = -1
    return str(res)

if __name__ == '__main__':
    print(solve())


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

#define pb push_back

#define ll long long

#define ft first

#define sd second

using namespace std;

const int N = 5050 ;

bool used[N];

ll z , r , w ;

ll p = -1 ;

int main(){

    int n ;
    cin >> n ;
    string s ;
    cin >> s ;
    int a = 0 , b = 0 , c = 0 ;
    for(int i = 0 ; i < n ; i ++ ){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            a++;
        }
    }
    cout<<a;

}


Measured memory_bytes: 256
# Reference: https://note.nkmk.me/python-union-find/
class UnionFind:
    # if x is root: self.parents[x] = -(the number of the group nodes)
    # else: self.parents[x] = the parent of x
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # return the parent of x
    def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # merge the group of x and the group of y
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # return whether x and y in a same group
    def same(self, x, y):
        return self.find(x) == self.find(y)

def main():
    from sys import stdin
    input = stdin.buffer.readline
 
    n, q = map(int, input().split())
 
    uf = UnionFind(n)
 
    ans = []
    for _ in range(q):
        t, u, v = map(int, input().split())
        if t == 0:
            uf.union(u, v)
        else:
            if uf.same(u, v):
                ans.append(1)
            else:
                ans.append(0)
    
    for i in ans:
        print(i)
 
main()

Measured memory_bytes: 12400
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int t, a, index;
  double res = 0;
  cin>>t>>a;
  index = 0;
  res = 1e9;
  vector<int> vec(n, 0);
  vector<double> ans(n, 0);
  for(int i = 0; i < n; ++i)cin>>vec[i];
  for(int i = 0; i < n; ++i){
    ans[i] = (double)(t - vec[i] * 0.006);
  }
  for(int i = 0; i < n; ++i){
    if(abs(ans[i] - a) < res){
      res = abs(ans[i] - a);
      index = i;
    }
  }
  cout<<index + 1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip> 
#include<sstream>
#include <map>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n,m;
    while (cin >> m>>n)
    {
        int ans = 0;
        if (n >= m)
        {
            cout << "1" << '\n';
            continue;
        }
        ans = m / n;
        if (m % n > 0)ans++;
        cout << ans << '\n';
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int h, w;
int a[200009], b[200009];

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

    cin >> h >> w;
    rep(i, h) {
        cin >> a[i] >> b[i];
        a[i]--;
    }

    set<pair<int, int>> pst;
    multiset<int> st;

    pst.insert(make_pair(w, w));
    rep(i, w) {
        pst.insert(make_pair(i, i));
        st.insert(0);
    }

    rep(i, h) {
        while(1) {
            auto itr = pst.lower_bound(make_pair(a[i], 0));
            if(b[i] <= itr->first) break;
            auto itr2 = next(itr);
            st.erase(st.find(itr->first - itr->second));

            pair<int, int> p = *itr;
            pst.erase(itr);
            if(b[i] < itr2->first) {
                chmax(p.first, b[i]);
                pst.insert(p);
                st.insert(p.first - p.second);
                break;
            }
        }
        if(pst.size() <= 1) {
            cout << -1 << endl;
        } else {
            cout << i + 1 + *st.begin() << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 23908
//
// author  : Abhishek
//
#include <bits/stdc++.h>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

const db pi = 3.141592653589793238;

int main() {

//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll i, j, k, n, m, p, q, l, r;

    db a, b, x, A, y;

    cin >> a >> b >> x;

    A = a * b * (0.5);
    y = x / a;

    db ans;

    if (y <= A) {

        ans = atan((2 * x) / (a * b * b));
        db val = (ans * 180) / pi;
        cout << fixed << setprecision(9) << (db)90- val;
    } else {

        ans = atan((a) / (2 * b - ((2 * x) / (a * a))));
        db val = (ans * 180) / pi;
        cout << fixed << setprecision(9) << (db)90 - val;
    }


    return 0;
}




Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5000 + 10;
const ll mod = 1e9 + 7;
vector<int> E[maxn];
int siz[maxn];
ll facc[maxn], tmp[maxn][maxn], f[maxn][maxn][2];
void init()
{
	facc[1] = 1;
	for(int i = 3; i < maxn; i += 2)
		facc[i] = facc[i - 2] * i % mod;
}
void dfs(int x, int fa)
{
	siz[x] = 1; f[x][1][0] = 1;
	for(auto v : E[x])
		if(v != fa)
		{
			dfs(v, x);
			for(int j = 1; j <= siz[x] + siz[v]; ++j)
				for(int k = 0; k < 2; ++k)
				{
					tmp[j][k] = f[x][j][k];
					f[x][j][k] = 0;
				}
			for(int j = 1; j <= siz[x]; ++j)
				for(int k = 0; k < 2; ++k)
					for(int vj = 1; vj <= siz[v]; ++vj)
						for(int vk = 0; vk < 2; ++vk)
						{
							f[x][j + vj][k ^ vk] += tmp[j][k] * f[v][vj][vk] % mod;
							f[x][j + vj][k ^ vk] %= mod;
							f[x][j][k ^ vk ^ 1] += tmp[j][k] * f[v][vj][vk] % mod * facc[vj - 1] % mod;
							f[x][j][k ^ vk ^ 1] %= mod;
						}
			siz[x] += siz[v];
		}
}
int main()
{
	init();
	int n;
	scanf("%d", &n);
	for(int i = 1; i < n; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	dfs(1, 0);
	ll ans = 0;
	for(int i = 1; i <= siz[1]; ++i)
	{
		//cout << f[1][i][0] << ' ' << f[1][i][1] << ' ' << facc[i - 1] << endl;
		ans += (f[1][i][0] - f[1][i][1] + mod) * facc[i - 1] % mod;
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}
	
	

Measured memory_bytes: 587392
S = int(input())
import math

if S == 10**18:
    print(0,0,10**9,0,0,10**9)
else:
    Y3 = S // 10**9 + 1
    X3 = 10**9 - S % 10**9

    print(0,0,10**9,1,X3,Y3)

Measured memory_bytes: 38256
import bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
P=set(P)
A=[]
for i in range(110):
    if i not in P:
        A.append(i)
zahyo=bisect.bisect_left(A,X)
ans=[]
ans.append([abs(X-A[zahyo]),A[zahyo]])
ans.append([abs(X-A[zahyo-1]),A[zahyo-1]])
ans.sort()
print(ans[0][1])

Measured memory_bytes: 9220
while True:
    
    num = input().split()

    a = int(num[0])
    b = int(num[2])
    op = num[1]
    
    if op == "+":
        print(a + b)
    
    if op == "-":
        print(a - b)
    
    if op == "*":
        print(a * b)

    if op == "/":
        print(int(a / b))
    
    if op == "?":
        break


Measured memory_bytes: 5596
//file_name:ABC59_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    ll b[n];
    rep(i,n){
        scanf("%lld",&a[i]);
        b[i] = a[i];
    }


    ll ans = 0;
    ll sum = 0;
    rep(i,n){
        sum += a[i];
        if(i%2==0){
            if(sum<1){
                ans += 1 - sum;
                sum = 1;
            }
        }else{
            if(-1<sum){
                ans += 1 + sum;
                sum = -1;
            }
        }
    }

    ll ans2 = 0;
    sum = 0;
    rep(i,n){
        sum += a[i];
        if(i%2==1){
            if(sum<1){
                ans2 += 1 - sum;
                sum = 1;
            }
        }else{
            if(-1<sum){
                ans2 += 1 + sum;
                sum = -1;
            }
        }
    }

    cout << min(ans,ans2) << endl;
    return 0;
}



Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target("avx")
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

ll dp[101][100001];

int main(void){
    cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,W;
	cin>>n>>W;
	vl w(n),v(n);
	rep(i,n) cin>>w[i]>>v[i];
	rep(i,n){
	    rep(j,W+1){
	        if(i==0){
	            if(j>=w[i]) dp[i][j] = v[i];
	        }
	        else{
	            dp[i][j] = max(dp[i][j],dp[i-1][j]);
	            if(j>=w[i]) dp[i][j] = max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
	        }
	    }
	}
	cout<<dp[n-1][W]<<endl;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n;cin>>n;
  int m=n+1;m/=2;
  cout<<fixed<<setprecision(10);
  cout<<(double)m/(double)n<<endl;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n][3];
    int dp[n + 1][3];
    rep (i, n) {
        rep (j, 3) {
            cin >> a[i][j];
        }
    }
    rep (i, n + 1) {
        rep (j, 3) {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = 0, dp[0][1] = 0, dp[0][2] = 0;
    rep (i, n) {
        rep (j, 3) {
            rep (k, 3) {
                if (j == k) continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));


    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int num = 0;
    int left = 0;
    int ans = 0;
    rep(i,N){
        while(left<=i){
            if((num^A[i]) == num+A[i]){
                num ^= A[i];
                break;
            }
            else{
                num ^= A[left];
                ++left;
            }
        }
        ans += i-left+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    
    if (a <= b && 0 < a)
        cout << "Positive";
    else if (a < 0 && b < 0){
        if ((a - b) % 2 == 0)
            cout << "Negative";
        else
            cout << "Positive";
    }
    else if(a <= 0 && 0 <= b)
        cout << "Zero";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//stayCalmNeverSettle
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define szof(x) ((int)x.size())
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii; 
int const INF = (int)1e9+1e3;
ll const INFL = (ll)1e18+1e6;

const int N = 1e5+5;

bool check(int a,int b,int c,int k,int i){
	// cout << "flag2" << endl;
	// cout << k << endl;
	if(c>b && b>a){
		// cout << 1 << endl;
		return true;
	}
	if(k==0){
		// cout << 2 << endl;
		return false;
	}
	if(i==0){
		k--;
		bool temp =  check(2*a,b,c,k,0)||check(2*a,b,c,k,1)||check(2*a,b,c,k,2);
		return temp;
	}
	else if(i==1){
		k--;
		return check(a,2*b,c,k,0)||check(a,2*b,c,k,1)||check(a,2*b,c,k,2);
	}
	else{
		k--;
		return check(a,b,2*c,k,0)||check(a,b,2*c,k,1)||check(a,b,2*c,k,2);
	}
}

    
int main(){
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
    // int t = 1;
    // cin >> t;
    int a,b,c,k;
	cin >> a >> b >> c;//r,g,b
	cin >> k;
	if(c>b && b>a){
		cout << "Yes" << endl;
		return 0;
	}
	// cout << "flag" << endl;
	if(check(a,b,c,k,0)||check(a,b,c,k,1)||check(a,b,c,k,2)){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, n, k);
  wt((n - 1 + k - 2) / (k - 1));
}


Measured memory_bytes: 3620
#include <cstdio>
#include <queue>

using namespace std;
struct point {
    int x;
    int y;
};

struct point operator + (const point& p, const int dp[2]) {
    point result;
    result.x = p.x+dp[0]; result.y = p.y+dp[1];
    return result;
}

bool operator == (const point& p, const point& q) {
    return p.x == q.x && p.y == q.y;
}

bool operator <= (const point& p, const point& q) {
    return p.x <= q.x && p.y <= q.y;
}

int main () {
    point p, g, pn, min;
    int H, W, i, j, black=0;
    int next[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
    scanf("%d %d",&H,&W);
    p.x = 0  ; p.y = 0;
    g.x = H-1; g.y = W-1;
    min.x = 0; min.y = 0;
    char map[H][W+1];
    int d[H][W];
    for (i=0; i<H; i++) {
        scanf("%s",map[i]);
        for (j=0; j<W; j++) 
            if (map[i][j] == '#') black++;
    }
    queue<point> Q;
    map[p.x][p.y] = '#';
    d[p.x][p.y] = 0;
    d[g.x][g.y] = 0;
    Q.push(p);
    while (Q.size() != 0) {
        p = Q.front(); Q.pop();
        if (p == g) break;
        for (i=0; i<4; i++) {
            pn = p + next[i];
            if (min <= pn && pn <= g && map[pn.x][pn.y] != '#') {
                map[pn.x][pn.y] = '#';
                d[pn.x][pn.y] = d[p.x][p.y] + 1;
                Q.push(pn);
            }
        }
    }
    printf("%d\n", (d[g.x][g.y]==0) ? -1 : H*W-black-d[g.x][g.y]-1 );
    return 0;
}

Measured memory_bytes: 256
from math import ceil
A, B=map(int, input().split())

Alist=[i for i in range(ceil(A/0.08),int((A+1)/0.08))]
Blist=[i for i in range(ceil(B/0.1),int((B+1)/0.1))]

if set(Alist)&set(Blist):
  print(min(set(Alist)&set(Blist)))
else:
  print("-1")



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
    int n;
    cin>>n;
    int a[n];
   long long int sum=0;
     int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
   ans=a[1];
   for(int i=2;i<=n;i++)
   {
       if(ans>a[i])
       {
           sum+=(ans-a[i]);
       }
       else
       {
           ans=max(ans,a[i]);
       }
   }
   cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4356
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
 long long a,b,x;
 cin>> a >> b >> x;
 long long ans;
 if(a==0)  {
  ans = b/x + 1 ;
 }
 else{
  ans = b/x-(a-1)/x;
 }
 cout << ans <<endl;

 
}


Measured memory_bytes: 256