akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    ll k;
    cin >> n >> k;

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

    int visited[n+1];
    for (int i=1; i<=n; i++) {
        visited[i] = 0;
    }

    int ans = 1;
    ll loop = 0;
    visited[ans] = 0;
    for (ll i=1; i<=k; i++) {
        auto prev = visited[ans];
        if (prev != 0) {
            //cerr << "found loop at:" << i << " ans:" << ans << " prev:" << prev << endl;
            ll loop = i - prev;
            i += ((k - i) / loop) * loop;
            //cerr << "loop size:" << loop << " i:" << i << endl;
            while (i <= k) {
                ans = a[ans];
                i++;
            }
            break;
        }
        visited[ans] = i;
        ans = a[ans];
    }

    cout << ans << endl;
}


Measured memory_bytes: 5212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,c;
		int divisor = 0;

		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		for (int i = a; i <= b; i++)
			if (i != 0 && c % i == 0)divisor++;
		
		System.out.printf("%d\n", divisor);
	}
}

Measured memory_bytes: 26236
#include <bits/stdc++.h>
#define int long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//typedef long long int int;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100100100;
int a[100010],b[100010];

signed main(){
  int A,B,m;cin>>A>>B>>m;
  int ans=INF;
  REP(i,A)cin>>a[i];
  REP(i,B)cin>>b[i];
  REP(i,m){
    int x,y,c;cin>>x>>y>>c;x--;y--;
    ans=min(ans,a[x]+b[y]-c);
  }
  sort(a,a+A);
  sort(b,b+B);
  ans=min(ans,a[0]+b[0]);
  cout<<ans<<endl;
  
    
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main() {
ll H;
  ll W;
  cin >>H>>W;
  char data[H][W];
  rep(i,H) {
rep(j,W) {
  cin >>data[i][j];
}
  }
  
  ll count=0;
  rep(i,H) {
    rep(j,W) {
      if(data[i][j]=='#') {
        count++;
      }
    }
  }
  
  ll co=0;
  repl(i,1,H-1) {
repl(j,1,W-1) {
  if((data[i][j]=='#') &&((data[i][j-1]=='#')||(data[i-1][j]=='#')||(data[i][j+1]=='#')||(data[i+1][j]=='#')))   {
    co++;
  }
}
  }
  //cout<<co<<"B"<<endl;
  
  if((data[0][0]=='#') &&((data[0][1]=='#') ||(data[1][0]=='#'))) {
    co++;
  }
  if((data[H-1][0]=='#') &&((data[H-1][1]=='#') ||(data[H-2][0]=='#'))) {
    co++;
  }
  
  if((data[0][W-1]=='#') &&((data[0][W-2]=='#') ||(data[1][W-1]=='#'))) {
    co++;
  }
  
  if((data[H-1][W-1]=='#') &&((data[H-2][W-1]=='#') ||(data[H-1][W-2]=='#'))) {
    co++;
  }
  
  //cout<<co<<"A"<<endl;
  
  
  
  repl(i,1,H-1) {
    if((data[i][0]=='#') &&((data[i-1][0]=='#') ||(data[i+1][0]=='#')||(data[i][1]=='#'))) {
      co++;
    }
  }
     repl(i,1,H-1) {
    if((data[i][W-1]=='#') &&((data[i-1][W-1]=='#') ||(data[i+1][W-1]=='#')||(data[i][W-2]=='#'))) {
      co++;
    }
     }
     repl(i,1,W-1) {
    if((data[0][i]=='#') &&((data[0][i-1]=='#') ||(data[0][i+1]=='#')||(data[1][i]=='#'))) {
      co++;
    }
     }
  repl(i,1,W-1) {
    if((data[H-1][i]=='#') &&((data[H-1][i-1]=='#') ||(data[H-1][i+1]=='#')||(data[H-2][i]=='#'))) {
      co++;
    }
  }
  
  
  if(count==co) {
    cout<<"Yes"<<endl;
  }
    else {
      cout<<"No"<<endl;
    }

    
  }
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    int n,k,ans;
    cin>>n>>k;
    if(n<k) ans=min(n,abs(n-k));
    else if(n%k==0) ans=0;
    else
    {
        int temp=n/k;
        n=n-temp*k;
        ans=min(n,abs(n-k));
    }
    cout<<ans<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


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

int main() {

	char alpha;

	cin >> alpha;

	/*
	�p�������͕����R�[�h��ɏ��ɕ���ł���̂œ��͂ɂP�𑫂��Ύ��̕����ɂȂ�B
	*/
	alpha++;

	cout << alpha << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	ll n;
	cin >> n;
	ll a[5];
	if (n < 1000)
		cout << "ABC" << endl;
	else
		cout << "ABD" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int H, W;
int h, w;

int main() {
	cin >> H >> W;
	cin >> h >> w;
	cout << (H - h) * (W - w) << endl;
}

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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define b_e(a) a.begin(),a.end() //sort(b_e(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //


int main(){

  string S, T;
  S = is();
  T = is();
  ll slen = SZ(S);
  ll tlen = SZ(T);

  ll ans = INF;
  rep(i, slen-tlen+1){
    string s = S.substr(i, tlen);

    ll tmp = 0;
    rep(j, tlen){
      if (s[j] != T[j]) tmp++;
    }
    chmin(ans, tmp);
  }

  cout << ans << endk;





}

Measured memory_bytes: 3636
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
const long long md=1e9+7;
long long n,k,cnt[2020][2020];
int main()
{
	cin>>n>>k;
	for(int i=0;i<=2005;i++)
	{
		cnt[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			cnt[i][j]=(cnt[i-1][j-1]+cnt[i-1][j])%md;
		}
	}
	for(int i=1;i<=k;i++)
	{
		cout<<(cnt[k-1][i-1]*cnt[n-k+1][i])%md<<endl;
	}
	return 0;
}

Measured memory_bytes: 30464
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

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;

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<int> B(N);
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    vector<int> C(N - 1);
    for (int i = 0; i < N - 1; i++) {
        cin >> C[i];
    }

    int ans = 0;
    int lastA = -1;
    for (int i = 0; i < N; i++) {
        ans += B[A[i] - 1];
        if (lastA == A[i] - 1) {
            ans += C[lastA - 1];
        }
        lastA = A[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;

	public static void main(String[] args) {

		int N=sc.nextInt();
		
		
		Map<String, Integer> map = new HashMap<String, Integer>(N);

		for(int i=0;i<N;i++) {
			String v=sc.next();
			if(map.containsKey(v)) {
				map.replace(v, map.get(v)+1);
			}else {
				map.put(v, 1);
			}
		}
		int M=sc.nextInt();
		Map<String, Integer> map2 = new HashMap<String, Integer>(M);
		for(int i=0;i<M;i++) {
			String v=sc.next();
			if(map2.containsKey(v)) {
				map2.replace(v, map2.get(v)+1);
			}else {
				map2.put(v, 1);
			}
		}
		int ans=0;
		for(String v:map.keySet()) {
			int a=map.get(v);
			int b=0;
			if(map2.containsKey(v)) {
				b=map2.get(v);
			}
			ans=Math.max(ans, a-b);
		}
		p(ans);
		
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
int arr[N];
vector<int> v1,v0;
int a[N],b[N];
map<int,int> mp;
signed main(){
	string str;
	cin>>str;
	int n=str.size();int ans=0;
	for(int i=0;i<(1<<(n-1));i++){
		int temp=(str[0]-'0');
		for(int j=0;j<n;j++){
			
			if(i&(1<<j)||j==n-1){ //有 
				ans+=temp;
				temp=0;
				
				//break;
			}
			temp=temp*10+(str[j+1]-'0');
			
			//add*=10;
			
		}
	}
	cout<<ans;
	return 0;
}
/*
*/

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>

int main(){
    int32_t N;
    std::cin >> N;
    constexpr int64_t INF = 1LL<<60;
    int64_t abs_min = INF;
    int64_t abs_sum = 0;
    int32_t num_minus = 0;
    for(int32_t i = 0; i < N; i++){
        int64_t Ai;
        std::cin >> Ai;
        if(Ai < 0) num_minus++;
        abs_min = std::min(abs_min, std::abs(Ai));
        abs_sum += std::abs(Ai);
    }
    if(num_minus % 2 == 1){ 
        abs_sum -= 2 * abs_min;
    }

    std::cout << abs_sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n;
    cin >> n;
    vector<int> v(n+1);
    rep(i, 1, n + 1)
        cin >> v[i];
    vector<int> res;
    vector<int> cnt(n+1);
    bool y = true;
    for (int i = n; i >= 1; i--)
    {
        int sum = 0LL;
        for (int j = n - n % i; j >= 1 && j != i; j -= i)
        {
            sum += cnt[j];
            // cout << j << " ";
        }
        if (sum % 2 != v[i])
        {
            res.push_back(i);
            cnt[i] = 1;
        }
        // if (v[i] == 1)
        // cout << i << " -> ";
        // cout << endl;
    }
    cout << res.size() << endl;
    rep(i, 0, res.size())
        cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 7264
N,K = map(int,input().split())
items = tuple(tuple(map(int,input().split())) for _ in range(N))

def it():
  i = 1
  while i <= K:
    if K & i:
      j = (K^i)|(i-1)
      yield sum(b for a,b in items if a&~j==0)
    i <<= 1
  yield sum(b for a,b in items if a&~K==0)

print(max(it()))

Measured memory_bytes: 18676
#include"bits/stdc++.h"
using namespace std;

void Main() {
  char n[3];
  cin >> n[0] >> n[1] >> n[2];
  
  for (int i = 0; i < 3; i++) {
    if (n[i] == '1') cout << 9;
    else cout << 1;
  }
  cout << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int shuku = 0;
        if (k > n) {
            shuku = x * n;
        } else {
            shuku = x * k;
            shuku += (n - k) * y;
        }
        System.out.println(shuku);
    }

}

Measured memory_bytes: 9544
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author test
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc187_b solver = new abc187_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc187_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long aa = in.nextLong();
            long bb = in.nextLong();
            long cc = in.nextLong();
            long dd = in.nextLong();
            long max = Long.MIN_VALUE;

            //out.println(Math.max(aa*cc,Math.max(aa*dd,Math.max(bb*cc,dd*bb))));


            max = Math.max(max, aa * cc);
            max = Math.max(max, aa * dd);
            max = Math.max(max, bb * cc);
            max = Math.max(max, bb * dd);

            out.println(max);

        /*
        int X = Math.max(aa,bb);
        int Y = Math.max(cc,dd);

         */


        /*
        long X = aa<bb?bb:aa;
        long Y = cc<dd?dd:cc;

        if (bb<0 && dd<0){
            out.println(aa * dd);
            return;
        } else if (cc>0 && dd<0) {
            out.println(aa*dd);
            return;

        }
        out.println(X*Y);

         */
/*
        if ((X <0) && (Y>=0))
        {

        }

        if (X<Y) {
            if (X<0) {
                Y = cc;
            }
        } else if (X>Y) {
            if (Y<0) {
                X = aa;
            }
        }
        out.println(X*Y);
         */
        }

    }
}



Measured memory_bytes: 35884
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

A, B = map(int, input().split())
print(int(A*B))

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>> &pq) {return (ll)pq.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>, greater<T>> &pq) {return (ll)pq.size(); }
ll sz(string &s) {return (ll)s.size(); } 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

int main(){
    ll n,m;
    cin >> n >> m;
    dsu d(n);
    ll a,b;

    rep(i,0,m){
        cin >> a >> b;
        a--;b--;
        d.merge(a,b);
        d.merge(b,a);
    }

    vector<ll> vec;
    rep(i,0,n){
        vec.push_back(d.leader(i));
    }
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()),vec.end());

    cout << sz(vec) - 1 << endl;
    return 0;
}



Measured memory_bytes: 4744
int main()
{
	char string[16];
	scanf("%s",string);
	int i;
	if (string[0] != 'C') i++;
	if (string[1] != 'O') i++;
	if (string[2] != 'D') i++;	
	if (string[3] != 'E') i++;
	if (string[4] != 'F') i++;
	if (string[5] != 'E') i++;
	if (string[6] != 'S') i++;
	if (string[7] != 'T') i++;
	if (string[8] != 'I') i++;
	if (string[9] != 'V') i++;
	if (string[10] != 'A') i++;
	if (string[11] != 'L') i++;
	if (string[12] != '2') i++;
	if (string[13] != '0') i++;
	if (string[14] != '1') i++;
	if (string[15] != '6') i++;

	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int n, a[100011],b, ans = 0,m = 0;cin >> n;
	rep(i, 100011) a[i] = 0;
	rep(i, n) { 
		cin >> b; a[b]++;
	}
	for (int i = 1;i < 100010 ; i++) {
		ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
	}
	cout << ans << endl;
}


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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int n, len;
string s;

int checkA() {
  int i=2, j=len-2;
  while(i<j) {
    if(s[i] != '=' || s[j] != '=') return 0;
    i++; j--;
  }

  if(s[i] == '#' && s[len-1] == '~') return 1;
  return 0;
}

int checkB() {
  if(s[len-1]!='~' || s[len-2]!='~') return 0;
  for(int i=2; i<len-2; i+=2) {
    if(s[i] != 'Q' || s[i+1] != '=') return 0;
  }

  return 2;
}

int solve() {
  if(len<6 || len%2 == 1) return 0;
  if(s[0] == '>' && s[1] == '\'') return checkA();
  if(s[0] == '>' && s[1] == '^')  return checkB();
  return 0;
}

int main() {

  cin>> n;
  while(n--) {
    cin>> s;
    len = s.size();
    int ans = solve();
    if(ans == 0) cout<< "NA";
    if(ans == 1) cout<< 'A';
    if(ans == 2) cout<< 'B';
    cout<< endl;
  }
}

Measured memory_bytes: 1196
N_ko, M_d, Const = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0

for i in range(N_ko):
    summ = 0
    
    A = list(map(int, input().split()))
    
    for j in range(M_d):
        summ += A[j] * B[j]
    
    if (summ + Const > 0):
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>

const int MAX = 100;
static int time = 0;
int adj[MAX][MAX];
int discover[MAX];
int finish[MAX];

void visit(int node, int n)
{
  ++time;
  discover[node] = time;

  for (int i = 0; i < n; ++i)
  {
    if (adj[node][i] == 1 && discover[i] == 0)
      visit(i, n);
  }

  ++time;
  finish[node] = time;
}

int main()
{
  std::memset(adj, 0, sizeof(adj));
  std::memset(discover, 0, sizeof(discover));
  std::memset(finish, 0, sizeof(finish));

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

  int u, k, v;
  for (int i = 0; i < n; ++i)
  {
    scanf("%d%d", &u, &k);
    for (int j = 0; j < k; ++j)
    {
      scanf("%d", &v);
      adj[u - 1][v - 1] = 1;
    }
  }

  for (int i = 0; i < n; ++i)
  {
    if (discover[i] == 0)
      visit(i, n);
  }

  for (int i = 0; i < n; ++i)
    printf("%d %d %d\n", i + 1, discover[i], finish[i]);

  return 0;
}


Measured memory_bytes: 2768
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, D: int, E: int):
    def func(n):
        return 0 if n % 10 == 0  else 10 - n % 10
    F = [A, B, C, D, E]
    G = list(map(func, F))
    H = [f+g for f, g in zip(F, G)]
    return sum(H) - max(G)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    print(solve(A, B, C, D, E))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 10000
#define N -1
struct node{
  int a,b,c;
};
struct node T[MAX];
int n;
void preparse(int);
void inparse(int);
void postparse(int);

int main(){
  int i,v,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].a = N;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].b=l;
    T[v].c=r;

    if(l != N){
      T[l].a=v;
    }
    if(r != N){
      T[r].a=v;
    }
  }
    for(i=0;i<n;i++){
      if(T[i].a == N){
        root = i;
      }
    }

    printf("Preorder\n");
    preparse(root);
    printf("\n");
    printf("Inorder\n");
    inparse(root);
    printf("\n");
    printf("Postorder\n");
    postparse(root);
    printf("\n");
    return 0;
}
void preparse(int y){
  if(y == N){
    return;
  }
  printf(" %d",y);
  preparse(T[y].b);
  preparse(T[y].c);
}
void inparse(int u){
  if(u == N){
    return;
  }
  inparse(T[u].b);
  printf(" %d",u);
  inparse(T[u].c);
}
void postparse(int u){
  if(u == N){
    return;
  }
  postparse(T[u].b);
  postparse(T[u].c);
  printf(" %d",u);
}



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

int main(){
    int n,q,sum=0;
    scanf("%d",&n);
    int S[n];

    for(int i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    scanf("%d",&q);
    int tmp;

    for(int i=0;i<q;i++){
        scanf("%d",&tmp);
        for(int j=0;j<n;j++){
            if(tmp==S[j]){
                sum++;
                break;
            }
        }
    }
    printf("%d\n",sum);
}


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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

fn main() {
    // println!("{}", solve(&stdin!()));
    solve(&stdin!());
}

fn solve(src: &str) {
    input!{
        source = src,
        n: isize,
        ss: [String; n]
    }

    let mut v = vec![0, 0, 0, 0]; //  AC, WA, TLE, RE

    for s in ss {
        if s == "AC" {
            v[0] += 1;
        } else if s == "WA" {
            v[1] += 1;

        } else if s == "TLE" {
            v[2] += 1;
        } else {
            v[3] += 1;
        }

    }



    println!("AC x {}", v[0]);
    println!("WA x {}", v[1]);
    println!("TLE x {}", v[2]);
    println!("RE x {}", v[3]);
}


Measured memory_bytes: 7712
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

template<typename T>
struct BIT {
  int n;
  std::vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

ll N, K;
ll a[200010], S[200010];
std::set<ll> st;
std::map<ll, ll> ip, vp;

int main() {
  std::cin >> N >> K;

  rep( i, N )
    std::cin >> a[i], a[i] -= K;

  rep( i, N )
    S[i+1] = S[i]+a[i];

  rep( i, N+1 )
    st.emplace( S[i] );

  ll p = 0;

  for( auto v : st ) {
    ip[v] = p;
    vp[p] = v;

    ++p;
  }

  BIT<ll> bit(st.size()+10);

  ll ans = 0;

  rep( i, N+1 ) {
    ans += bit.sum( ip[S[i]] );

    bit.add( ip[S[i]], 1 );
  }

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 42304
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007

ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) { return m / gcd(n, m) * n; }

int main(void) {
	int x,i=1;
	while (cin >> x && x) {
		cout << "Case " << i << ": " << x << endl;
		i++;
	}
	return 0;
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	double a, b;
  	double mean;
  	cin >> a >> b;
  	mean = (a + b) / 2;
    if(mean - int(mean) == 0){
      cout << mean << endl;
    }else{
      cout << int(mean) + 1 << endl;
    }
}

Measured memory_bytes: 256
import itertools

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
youso = []
zyunretu =[]
iti1 = 0
iti2 = 0
for x in range(n):
    youso.append(x+1)

for v in list(itertools.permutations(youso)):
    if str(a)[1 :-1] == str(v)[1 :-1] :
        iti1 = len(zyunretu)+1
    if str(b)[1 :-1] == str(v)[1 :-1] :
        iti2 = len(zyunretu)+1
    zyunretu.append(str(v)[1 :-1])

print(abs(iti1 - iti2))

Measured memory_bytes: 17508
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define REP(i, vec) for(auto i = vec.begin(); i != vec.end(); ++i)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T> inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T> inline T LCM(T a, T b) { return (a + (b - 1)) / b; }

int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n) :fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

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

    combination c(n);

    for (int i = 1; i <= k; ++i) {
        if (i > n - k + 1) {
            cout << 0 << endl;
        }
        else {
            mint ans = c(n - k + 1, n - k - i + 1) * c(k - 1, k - i);
            cout << ans.x << endl;
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;


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

    string s;
    cin >> s;
    if (s.back() == 's')
    {
        s += "es";
    }
    else
    {
        s += "s";
    }
    cout << s << "\n";

}


Measured memory_bytes: 3628
def main():
    x,k,d=map(int,input().split())
    x = abs(x)
    c = x//d
    if k < c:
        print(x-k*d)
    else:
        x = x%d
        k -= c
        x = [x, x-d]
        print(abs(x[k%2]))

if __name__ == '__main__':
    main()

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n, m; cin >> n >> m;
        vector<int> connected[m];
        for (int i = 0; i < m; i++) {
                int x; cin >> x;
                while (x--) {
                        int y; cin >> y;
                        connected[i].emplace_back(y - 1);
                }
        }

        vector<int> parity(m); cin >> parity;

        int ans = 0;
        for (int mask = 0; mask < (1 << n); mask++) {
                bool good = 1;
                for (int i = 0; i < m; i++) {
                        int on = 0;
                        for (auto s: connected[i]) {
                                if (1 << s & mask) on++;
                        }
                        if (on % 2 != parity[i]) good = 0;
                }
                ans += good;
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

using namespace std;

int calc(int start, int time) {
  int res = start + time;
  int r = res % 10;
  return r ? res - r + 10 : res;
}

int main() {
  int t[5];
  for (int i = 0; i < 5; i++) {
    cin >> t[i];
  }

  int ans = 1000000;
  for (int i = 0; i < 5; ++i) {
    for (int j = 0; j < 5; ++j) {
      for (int k = 0; k < 5; ++k) {
        for (int l = 0; l < 5; ++l) {
          for (int m = 0; m < 5; ++m) {
            if (i != j && i != k && i != l && i != m && j != k && j != l &&
                j != m && k != l && k != m && l != m) {
              int time = calc(0, t[i]);
              time = calc(time, t[j]);
              time = calc(time, t[k]);
              time = calc(time, t[l]);
              time += t[m];
              ans = min(ans, time);
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
import bisect
from collections import defaultdict

def main():
    N, K = map(int, input().split())
    V_list = list(map(int, input().split()))

    max_value = -10**7
    for num_get in range(K+1):
        if num_get > N:
            continue
        max_return = K - num_get
        for num_left in range(num_get+1):
            num_right = num_get - num_left
            V_obtained = list(V_list[:num_left])
            V_obtained += list(V_list[N-num_right:])
            V_obtained = sorted(V_obtained)
            for num_return in range(max_return+1):
                value = sum(V_obtained[num_return:])
                if max_value < value:
                    max_value = value

            if len(V_obtained) == 0:
                value = 0
                if max_value < value:
                    max_value = value

    print(max_value)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int d[] = new int[101];
		int cnt[] = new int[101];
		int n = 0;
		int cntA = 0;
		
		for(int i=0; i<K; i++){
			d[i] = sc.nextInt();
			for(int j =0; j<d[i]; j++) {
				n =sc.nextInt();
				cnt[n-1] = cnt[n-1]+1;
			}
		}		
		
		for(int i=0; i<N; i++) {
			if(cnt[i] == 0) {
				cntA +=1;
			}
		}

		System.out.println(cntA);
		sc.close();
	}
}

Measured memory_bytes: 46700
/*input
9
4 2 5 8 3 6 1 7 9
6 8 8 4 6 3 5 7 5
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
using namespace std;
#define N  100005
map <lld,lld> bt,bt2;
void add2(lld val,lld inc)
{
	for(lld i=val;i<1e9;i=i+(i&(-i)))
	{
		bt2[i]=max(inc,bt2[i]);
	}
}
lld ans2(lld val)
{
	lld fans=0;
	for(int i=val;i>0;i-=(i&(-i)))
	{
		fans=max(bt2[i],fans);
	}
	return fans;
}
void solve()
{
	lld n;
	cin >> n;
	lld a[n],b[n];
	rep(i,0,n)
	{
		cin >> a[i];
	}
	rep(j,0,n)
	{
		cin >> b[j];
	}
	lld fas=0;
	rep(i,0,n)
	{
		lld q1=ans2(a[i]);
		// cout << q1 << ' ' << a[i] <<endl;
		add2(a[i],q1+b[i]);
		fas=max(fas,q1+b[i]);
	}
	cout << fas << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int express[509][509];


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,q;
	cin>>n>>m>>q;
	FOR(i,0,m){
		int l,r;
		cin>>l>>r;
		express[0][r]++;
		express[l+1][n+1]++;
		express[0][n+1]--;
		express[l+1][r]--;
	}
	FOR(i,0,503){
		FOR(j,0,503){
			express[i][j+1]+=express[i][j];
		}
	}
	FOR(j,0,503){
		FOR(i,0,503){
			express[i+1][j]+=express[i][j];
		}
	}
	FOR(i,0,q){
		ll pi,qi;
		cin>>pi>>qi;
		cout<<m+express[pi][qi]-m<<endl;
	}
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int P = sc.nextInt();
        int Q = sc.nextInt();
        int R = sc.nextInt();
        System.out.println(Math.min(P+R, Math.min(P+Q, Q+R)));
    }
}

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

int main() {
	int n, t;
	cin >> n >> t;
	vector<int> path;
	for (int i = 0, c, u; i < n; i++) {
		cin >> c >> u;
		if (u <= t)
			path.emplace_back(c);
	}
	if (!path.empty()) {
		sort(path.begin(), path.end());
		cout << path[0] << endl;
	} else
		cout << "TLE" << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;


int main(){
  ll n;
  cin >> n;
  vll a(n);
  vvpll xy(n);
  rep(i, 0, n){
    cin >> a.at(i);
    rep(j, 0, a.at(i)){
      ll x, y;
      cin >> x >> y;
      x--;
      xy.at(i).push_back(make_pair(x, y));
    }
  }

  ll ans = 0;
  rep(bitt, 0, 1<<n){
    bitset<15> bit(bitt);
    bl check = true;
    rep(i, 0, n)rep(j, 0, a.at(i)) if(bit.test(i)){
      if(xy.at(i).at(j).second == 0 && bit.test(xy.at(i).at(j).first)) check = false;
      if(xy.at(i).at(j).second == 1 && !bit.test(xy.at(i).at(j).first)) check = false;
    }
    if(check) chmax(ans, (ll)bit.count());
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007




ll h, w, a, b, f[310000], ans = 0;

ll kn(ll aa, ll bb) {
	aa %= MOD;
	ll res = 1;
	while (bb > 0) {
		if (bb % 2 == 1)res *= aa;
		aa *= aa;
		bb /= 2;
		aa %= MOD;
		res %= MOD;
	}
	return res;
}

ll com(ll aa, ll bb) {
	return f[aa] * kn(f[aa - bb] * f[bb], MOD - 2) % MOD;
}

int main() {
	f[0] = 1;
	REPO(i, 300000)f[i] = f[i - 1] * i % MOD;
	cin >> h >> w >> a >> b;
	FOR(i, b + 1, w + 1) {
		ans += com(i + h - a - 2, h - a - 1) * com(a - 1 + w - i, a - 1);
		ans %= MOD;
	}
	cout << ans % MOD << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pa;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1<<18|3;
int n,a[N],b[N],dep[N],Q;

inline vector<pa> Merge(vector<pa>a,vector<pa>b){
	vector<pa>ret;
	int l=0,L=0;
	while (l<siz(a)&&L<siz(b))
		if (a[l].fi<b[L].fi) ret.pb(a[l++]);
			else ret.pb(b[L++]);
	while (l<siz(a)) ret.pb(a[l++]);
	while (L<siz(b)) ret.pb(b[L++]);
	return ret;
}
int cnt,p[N],q[N];
inline ll Query(int u,int lim){
	if (u==1) return a[u]*(b[u]<=lim);
	cnt=0;
	for (int now=u;now;now>>=1) p[++cnt]=b[now],q[cnt]=a[now];
	vector<pa>v={{p[1],q[1]}};
	int hf=cnt+1>>1;
	For(i,2,hf){
		vector<pa>tmp={{p[i],q[i]}};
		for (auto j:v) tmp.pb({j.fi+p[i],j.se+q[i]});
		v=Merge(v,tmp);
	}
	vector<pa>_v={{p[hf+1],q[hf+1]}};
	For(i,hf+2,cnt){
		vector<pa>tmp={{p[i],q[i]}};
		for (auto j:_v) tmp.pb({j.fi+p[i],j.se+q[i]});
		_v=Merge(_v,tmp);
	}
	int l=0;
	ll mx=0,ans=0;
	for (auto i:_v) if (i.fi<=lim) ans=max(ans,i.se);
	Dow(i,siz(v)-1,0){
		while (l<siz(_v)&&_v[l].fi+v[i].fi<=lim) mx=max(mx,_v[l].se),l++;
		if (v[i].fi<=lim) ans=max(ans,mx+v[i].se);
	}
	return ans;
}

int main(){
	n=read();
	For(i,1,n) a[i]=read(),b[i]=read(),dep[i]=dep[i>>1]+1;
	Q=read();
	For(i,1,Q){
		int v=read(),l=read();
		printf("%lld\n",Query(v,l));
	}
}

Measured memory_bytes: 6876