akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 24/Nov/19 06:03:25 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on

const int N = 1e5 + 5;
ve< int > graph[N];
int deg[N];
int n, ans;
map< pii, pii > edges;

void dfs (int node, int parent, int c) {
	for (int to : graph[node]) {
		if (to == parent) continue;

		edges[{min (node, to), max (node, to)}].ss = ++c;
		c %= ans;
		dfs (to, node, c);
	}
}

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	cin >> n;
	fr (i, 0, n - 1) {
		int u, v;
		cin >> u >> v;
		graph[u].pb (v);
		graph[v].pb (u);
		deg[u]++;
		deg[v]++;
		ans = max (ans, max (deg[u], deg[v]));
		if (u > v) swap (u, v);
		edges[{u, v}] = {i, -1};
	}
	dfs (1, 1, 0);
	ve< int > color (len (edges));
	for (auto& i : edges) {
		color[i.ss.ff] = i.ss.ss;
	}
	pr (ans);
	for (auto& i : color)
		pr (i);
	return 0;
}

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

signed main() {
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i=l; i<=r; i++) if(i%d == 0) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 3628
n, a, b = map(int, input().split())
MOD = 10**9 + 7

def combination(n, k):
    from math import factorial
    numer = 1
    for i in range(k):
        numer *= (n-i)
        numer %= MOD
    denom = factorial(k) % MOD
    return numer * pow(denom, MOD-2, MOD)

total = pow(2, n, MOD) - 1
comb_a = combination(n, a)
comb_b = combination(n, b)
print((total - comb_a - comb_b) % MOD)

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

public class Main {

	public static void main(String args[]) {
		FastScanner cin = new FastScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(FastScanner cin, PrintWriter cout) {
		int a = cin.nextInt();
		int b = cin.nextInt();
		if (a + b >= 10)
			cout.println("error");
		else
			cout.println(a + b);
	}

	/**
	 * How to read input in Java — tutorial <br />
	 * By Flatfoot<br />
	 * http://codeforces.com/blog/entry/7018
	 */
	static class FastScanner {
		private BufferedReader br;
		private StringTokenizer st;

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

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

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

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

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

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

}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> A(N);
    vector<long long int> S(N+1, 0);
    for(int n=0; n<N; n++) {
        cin >> A[n];
        S[n+1] = S[n]+A[n];
    }
    
    int l=0, r=1;
    long long int ans=0;
    while(r<=N) {
        // cout << l << ", " << r << endl;
        
        if(r==N) {
            ans += (long long int)(r-l)*(long long int)(r-l+1)/(long long int)2;
            break;
        }
        
        if(((S[r]-S[l])^A[r])==(S[r+1]-S[l])) {
            r++;
        } else {
            ans += (long long int)(r-l);
            l++;
            if(l==r) {
                r = l+1;
            }
        }
    }
    
    cout << ans << endl;


    return 0;
    
}

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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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

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

int MOD = (int) 1e9 + 7;

void solve() {
    int a,b;
    cin>>a>>b;
    set<int> u = {1,2,3};
    u.erase(a);
    u.erase(b);
    cout << *u.begin() << endl;
}


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

//    cout << solve() << endl;
    solve();
//    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    while(1)
    {
        int a,b,c,N,x,deta[1000],i,j,k,r,res[1000][3],count=0;
        scanf("%d %d %d",&a,&b,&c);
        if(a==0&&b==0&&c==0)break;
        scanf("%d",&N);
        for(x=1;x<=a+b+c;x++)
        {
            deta[x]=2;
        }
        for(x=0;x<N;x++)
        {
            scanf("%d %d %d %d",&i,&j,&k,&r);
            if(r==1)
            {
                deta[i]=1;deta[j]=1;deta[k]=1;
            }
            else
            {
                res[count][0]=i;res[count][1]=j;res[count][2]=k;
                count++;
            }
        }
        for(x=0;x<count;x++)
        {
            i=res[x][0];j=res[x][1];k=res[x][2];
            if(deta[j]==1&&deta[k]==1)
            {
               deta[i]=0;
            }
            if(deta[i]==1&&deta[k]==1)
            {
               deta[j]=0;
            }
            if(deta[i]==1&&deta[j]==1)
            {
               deta[k]=0;
            }
        }
        for(x=1;x<=a+b+c;x++)
        {
            printf("%d\n",deta[x]);
        }
    }
    return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;

int n, m, k, ans; char c[10][10];
bool chk(int s, int t) {
	int cnt = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if((s >> (i - 1) & 1) || (t >> (j - 1) & 1)) continue;
			else cnt += (c[i][j] == '#');
	return cnt == k;
}
signed main() {
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1; i <= n; i++)
		scanf("%s", c[i] + 1);
	for(int i = 0; i < (1 << n); i++)
		for(int j = 0; j < (1 << m); j++)
			if(chk(i, j)) ans++;
	printf("%d\n", ans);
	fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
	return 0;
	/* 取模直接除，爆零两行泪
	 * 不开ll见祖宗
	 */
}

Measured memory_bytes: 3708
X = str(input())
if X[0]=='R' and X[1]=='R' and X[2]=='R':
    print(3)
elif (X[0]=='R' and X[1]=='R') or (X[1]=='R' and X[2]=='R'):
    print(2)
elif X[0]=='R' or X[1]=='R' or X[2]=='R':
    print(1)
else:
    print(0)

Measured memory_bytes: 9028
ls = []

def add(t):
    if t not in ls:
        ls.append(t)

n = int(input())
for i in range(n):
    t = input()
    ls = [t] 
    for j in range(1,len(t)):
        f, b = t[:j], t[j:]
        add(f+b[::-1])
        add(f[::-1]+b)
        add(f[::-1]+b[::-1])
        add(b+f)
        add(b+f[::-1])
        add(b[::-1]+f)
        add(b[::-1]+f[::-1])
    print(len(ls))

Measured memory_bytes: 6780
n=int(input())
a=[0]+list(map(int,input().split()))
a.sort()
for i in range(n-1):
	if a[i]==a[i+1]==a[i+2]:
		print(0)
		exit()
double=[]
for i in range(n):
	if a[i]==a[i+1]:
		if a[i]==12 or a[i]==0:
			print(0)
			exit()
		else:
			double.append(a[i])
a=set(a);a=list(a)
b=[]
for x in a:
	if x not in double:
		b.append(x)
from copy import copy
a=copy(b)
n=len(a)
ans=0
def two(x):
	return (n-len(bin(x)[2:]))*"0"+bin(x)[2:]
for i in range(2**n):
	r=two(i)
	time=[0]*24
	time[0]=1
	for x in double:
		time[x]=1
		time[24-x]=1
	for j in range(n):
		if r[j]=="1":
			time[a[j]]=1
		else:
			if a[j]!=0:
				time[24-a[j]]=1
			else:
				time[0]=1
	pre_ans=24
	ren=0
	for j in range(1,24):
		if time[j]==0:
			ren+=1
		else:
			pre_ans=min(pre_ans,ren)
			ren=0
	pre_ans=min(pre_ans,ren)
	ans=max(ans,pre_ans+1)
print(ans)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int n,k;
vector<vector<int> > f,e;
 
struct node{
  int id,ty;
  node(){}
  void init(int x,int y){
    id=x;
    ty=y;
  }
  bool operator<(const node& a)const{
    for(int i=0;i<k;i++){
      if(f[id][e[ty][i]]!=f[a.id][e[ty][i]]) return f[id][e[ty][i]]>f[a.id][e[ty][i]];
    }
    return 0;
  }
};
node nodes[24][114514];
vector<int> G[114514];
set<node> ns[24];
signed main(){
  cin>>n>>k;
  f.resize(n,vector<int>(k));
  for(int i=0;i<n;i++){
    for(int j=0;j<k;j++){
      //cin>>f[i][j];
      scanf("%d",&f[i][j]);
    }
  }
  int d;
  cin>>d;
 
  int indeg[n];
  memset(indeg,0,sizeof(indeg));
  for(int i=0;i<d;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    indeg[b]++;
  }
  map<vector<int>,int> m;
  vector<int> v(k);
  for(int i=0;i<k;i++) v[i]=i;
  int cnt=0;
  do{
    for(int i=0;i<n;i++){
      nodes[cnt][i].init(i,cnt);
    }
    e.push_back(v);
    m[v]=cnt++;
  }while(next_permutation(v.begin(),v.end()));
 
  for(int j=0;j<cnt;j++){
    for(int i=0;i<n;i++){
      if(indeg[i]==0) ns[j].insert(nodes[j][i]);
      //if(indeg[i]==0) cout<<":"<<i<<endl;
    }
  }
 
  for(int i=0;i<k;i++) cin>>v[i],v[i]--;
  //cout<<m.count(v)<<endl;
  int ans=0,idx=m[v];
  //cout<<idx<<endl;
   
  int r;
  cin>>r;
  while(r--){
    int p;
    cin>>p;
    while(ans<p){
      int id=(ns[idx].begin())->id;
      for(int i=0;i<cnt;i++){
	//ns[i].insert(nodes[i][id]);
	//cout<<id<<":"<<ns[i].count(nodes[i][id])<<endl;
	//cout<<ns[i].size()<<" "<<ns[i].begin()->id<<endl;
	//cout<<(*ns[i].begin()==nodes[i][id])<<endl;
	ns[i].erase(nodes[i][id]);
      }
      for(int u:G[id]){
	indeg[u]--;
	if(indeg[u]==0){
	  for(int i=0;i<cnt;i++){
	    ns[i].insert(nodes[i][u]);
	  }
	}
      }
      //cout<<id+1<<endl;
      printf("%d\n",id+1);
      ans++;
    }
    for(int i=0;i<k;i++) cin>>v[i],v[i]--;
    idx=m[v];
    //cout<<idx<<endl;
  }
  while(ans<n){
    int id=ns[idx].begin()->id;
    for(int i=0;i<cnt;i++){
      //cout<<":"<<ns[i].count(nodes[i][id])<<endl;
      ns[i].erase(nodes[i][id]);
    }
    for(int u:G[id]){
      indeg[u]--;
      if(indeg[u]==0){
	for(int i=0;i<cnt;i++){
	  ns[i].insert(nodes[i][u]);
	}
      }
    }
    //cout<<id+1<<endl;
    printf("%d\n",id+1);
    ans++;
  }
  return 0;
}

Measured memory_bytes: 74404
#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include<vector>
#include <sstream>
#include <stdio.h>
#include <utility>
#include <unordered_set>
#include <valarray>
#include <iomanip>
using namespace std;


int main(void)
{
	struct PeakData
	{
		long int Higher;
		std::unordered_set<int> Route;
		bool Flag = true;
	};

	std::vector<PeakData> Datas;

	int PeakCount = 0;
	int RouteCount = 0;

	cin >> PeakCount >> RouteCount;

	Datas.resize(PeakCount);

	for (auto& Data:Datas)
	{
		cin >> Data.Higher;
	}

	int A, B = 0;
	for (int i=0;i<RouteCount;i++)
	{
		cin >> A >> B;
		Datas[A-1].Route.emplace(B-1);
		Datas[B-1].Route.emplace(A-1);
	}

	int OkCount = 0;

	for (auto& Data : Datas)
	{
		if (Data.Route.size()==0)
		{
			continue;
		}

		for (auto& ConnectPeak:Data.Route)
		{
			if (Data.Higher>=Datas[ConnectPeak].Higher)
			{
				Datas[ConnectPeak].Flag = false;
			}
		}
	}

	for (auto& Data : Datas)
	{
		OkCount += Data.Flag;
	}

	cout << OkCount << endl;
	return 0;
}

Measured memory_bytes: 17988
n, m = map(int, input().split())
if abs(n - m) < 2:
    cnt = 1
    for i in range(1, n + 1):
        cnt = (cnt * i) % (10 ** 9 + 7)
    for i in range(1, m + 1):
        cnt = (cnt * i) % (10 ** 9 + 7)
    print((cnt * 2) % (10 ** 9 + 7) if m == n else cnt)
else:
    print(0)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

#define MAX_V 1000000

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

	ll n, m;
	cin >> n >> m;
	ll x[n], y[m];
	rep(i, 0, n) cin >> x[i];
	rep(i, 0, m) cin >> y[i];

	ll tmp_x = 0, tmp_y = 0;
	rep(i, 0, n) tmp_x = (tmp_x + (i * 2 + 1 - n) * x[i]) % mod;
	rep(i, 0, m) tmp_y = (tmp_y + (i * 2 + 1 - m) * y[i]) % mod;

	cout << tmp_x * tmp_y % mod << endl;
	
}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;
using ll=long long;
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main() {
  int N, X;
  cin >> N >> X;
 
  vector<int> x(N+1);
  for (int i = 0; i < N; i++)
    cin >> x[i];
  x[N] = X;
 
  sort(x.begin(), x.end());


  for (int i = 1; i < N+1; i++)
    x[i]=x[i]-x[0];
  int ans;
  ans = gcd(x[1],x[2]);

  for (int i = 2; i < N+1; i++)
    ans = gcd(ans,x[i]);

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

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
vector<int> i;
vector<int> u;
vector<int> o;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b,c,d=0,e=0,f=0,g;
  string s;
  cin >>a>>b>>c;
  cin >>s;
  for(int n=0;n<a;n++){
    if(d<b+c){
      if(s[n]=='c') cout <<"No\n";
      else{
	if(s[n]=='b'){
	  if(e<c) d++,cout <<"Yes\n";
	  else cout <<"No\n";
	}
	else d++,cout <<"Yes\n";
      }
    }
    else cout <<"No\n";
    if(s[n]=='b') e++;
  }
  return (0);
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int n,a;cin>>n;
  int sum_odd=0,sum4=0;
  rep(i,n){
    cin>>a;
    if(a%2==1)sum_odd++;
    if(a%4==0)sum4++;    
  }
  if(sum_odd+sum4==n)sum4++;
  cout<<(sum_odd>sum4?"No":"Yes")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using p_int = pair<int, int>;
int H, W;
char field[1000][1000];
p_int direction[4] = { make_pair(1, 0), make_pair(0, 1), make_pair(-1, 0), make_pair(0, -1) };
vector<p_int> blacks;

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

    cin >> H >> W;
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            cin >> field[y][x];
            if (field[y][x] == '#') {
                blacks.emplace_back(y, x);
            }
        }
    }

    int total = 0;
    while (true) {
        bool reverse = false;
        vector<p_int > next_blacks;
        for (auto b: blacks) {
            int y = b.first;
            int x = b.second;
            for (auto d: direction) {
                int ny = y + d.first;
                int nx = x + d.second;
                if (0 <= ny && ny < H && 0 <= nx && nx < W && field[ny][nx] == '.') {
                    next_blacks.emplace_back(ny, nx);
                    field[ny][nx] = '#';
                    reverse = true;
                }
            }
        }
        // for (int y = 0; y < H; ++y) {
        //     for (int x = 0; x < W; ++x) {
        //         if (field[y][x] == '#') {
        //             for (auto d: direction) {
        //                 int ny = y + d.first;
        //                 int nx = x + d.second;
        //                 if (0 <= ny && ny < H && 0 <= nx && nx < W && field[ny][nx] == '.') {
        //                     field[ny][nx] = 'x';
        //                     reverse = true;
        //                 }
        //             }
        //         }
        //     }
        // }
        if (!reverse) {
            break;
        }
        blacks.clear();
        for (auto b: next_blacks) {
            blacks.push_back(b);
        }
        
        // for (int i = 0; i < H; ++i) {
        //     for (int j = 0; j < W; ++j) {
        //         if (field[i][j] == 'x') {
        //             field[i][j] = '#';
        //         }
        //     }
        // }
        total++;
    }

    cout << total << '\n';

    return 0;
}


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



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

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

    string O,E,p;

    cin>>O>>E;

    int a=O.length();
    int b=E.length();

    for(int i=0;i<(a+b);i++){
        if(i&1){
            p+=E[i/2];
        }else{
            p+=O[i/2];
        }
    }

    cout<<p<<endl;

}


Measured memory_bytes: 3664
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
if k in seta:
    print('POSSIBLE')
    sys.exit(0)

def gojoho(l, s):
    return s if l % s == 0 else gojoho(s, l % s)

koubaisu = gojoho(a[1], a[0])
for i in a:
    koubaisu = gojoho(i, koubaisu)

if k % koubaisu == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14508
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define rev(s) (string((s).rbegin(), (s).rend()))
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

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

    vector<int> a(n),b(n),c(n-1);

    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n-1) cin>>c[i];
    
    a.push_back(0);
    int ans=0;
    for (int i=0;i<n;i++) {
        ans+=b[a[i]-1];
        if (a[i]+1==a[i+1]) {
            ans+=c[a[i]-1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int nmax = 40,abmax=10,inf =1000000;
int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax*abmax + 1][nmax*abmax + 1];

int main() {
	int n, ma, mb;
	cin >> n >> ma >> mb;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >>  b[i] >> c[i];
	}
	for (int i = 0; i <= n; i++) {
		for (int ca = 0; ca <= nmax * abmax; ca++) {
			for (int cb = 0; cb <= nmax * abmax; cb++) {
				dp[i][ca][cb] = inf;
			}
		}
	}
	dp[0][0][0] = 0;//dp[i][j][k]=(i-1番目までみて...)
	for (int i = 0; i < n; i++) {
		for (int ca = 0; ca <= nmax * abmax; ca++) {
			for (int cb = 0; cb <= nmax * abmax; cb++) {
				if (dp[i][ca][cb] == inf) {
					continue;
				}
				dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
				dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
			}
		}
	}
	int ans = inf;
	for (int ca = 1; ca <= nmax * abmax; ca++) {
		for (int cb = 1; cb <= nmax * abmax; cb++) {
			if (ca*mb == cb * ma) {
				ans = min(ans, dp[n][ca][cb]);
			}
		}
	}
	if (ans == inf) {
		ans = -1;
	}
	cout << ans << endl;
	return 0;


}

Measured memory_bytes: 25984
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int hb = b/2;
		// 文字列の入力
	// 出力
		System.out.println(a + hb);
	}
}

Measured memory_bytes: 23764
N = int(input())
A = list(map(int, input().split()))

#Aiを二進数として，各けたを見れば良い？1の個数*0の個数

ans =0
mod =pow(10,9)+7

#Aiは最大で2^60-1
Max = 61

 #i桁目を見る
for i in range(Max):
    count = 0#その桁での1の数
    for j in range(N):
        if(A[j]>>i & 1)==1:
            count+=1
    ans+=count*(N-count)*pow(2,i)
    ans = ans%mod
print(ans)

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

using namespace std;

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

    int ans = 0;
    if (n>=13) ans = k;
    else if (n<=5) ans = 0;
    else	    ans = k/2;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#include <set>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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

using namespace std;

class C {
	string s;
	int k;
public:
	C()
	{
		cin >> s >> k;
	}

	void solve()
	{
		set<string> st;

		REP(left, SZ(s))
		{
			for (int right{ left + 1 }; right < SZ(s) + 1; right++)
			{

				if (SZ(st) < k)
				{
					st.insert(s.substr(left, right - left));
				}
				else
				{
					string sub{ s.substr(left, right - left) };
					if (sub < *(--st.end()))
					{
						if (!st.count(sub))
						{
							st.erase(--st.end());
							st.emplace(sub);
						}
					}
				}
			}
		}

		cout << *(--st.end()) << endl;

	}
};

int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9+7
    # check[i]:= Aの中のiが出てきた順番
    check = [[] for _ in range(N)]
    for i in range(N):
        check[A[i]].append(i)
    
    # print(check)
    ans = 1
    for i in range(len(check[0])):
        ans *= (3-i)

    for i in range(1,N):
        if len(check[i-1]) < len(check[i]):
            exit(print(0))
        # check[i]がcheck[i-1]のなかで何番目か調べる
        for j in range(len(check[i])):
            d = bisect_right(check[i-1],check[i][j])
            if d < j:
                exit(print(0))
            ans *= d-j
            ans %= p
            # print(ans)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 22244
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<10)cout<<n;
    else if(n>=10&&n<100)cout<<9;
    else if(n>=100&&n<1000)cout<<10+n-100;
    else if(n>=1000&&n<10000)cout<<909;
    else if(n>=10000&&n<100000)cout<<910+n-10000;
    else if(n==100000)cout<<90909;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    string S;
    map<char, int> m;

    cin >> S;
    for(int i = 0; i < 4; i++) {
        m[S[i]]++;
    }
    for(auto itr = m.begin(); itr != m.end(); itr++) {
        if(itr->second != 2) {
            cout << "No" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const double PI = 3.141592653589793238463;
const int MAXN = 1000500;
const int MAXVALUE = 1000000500;
const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k;
//vector <i64> a;
vector <i64> dp;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);
    long double a, b;
    cin >> a >> b;

    i64 res = (i64)(a*b);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL<<32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

string divide[4] = { "dream","dreamer","erase","eraser" };

signed main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;

	reverse(ALL(s));
	for (auto &d : divide)
		reverse(ALL(d));

	bool can = true;

	for (int i = 0; i < s.size();) {
		bool can2 = false;
		for(auto &d: divide){
			if (s.substr(i, d.size()) == d) {
				i += d.size();
				can2 = true;
			}
		}
		if (!can2) {
			can = false;
			break;
		}
	}
	if (can) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int A,B,C,X ;
  cin >> A >> B >> C >> X ;
  int ans =0 ;
  for(int a=0;a <= A;a++){
    for(int b=0;b <= B;b++){
      for(int c=0;c <= C;c++){
        int sum = 500*a+100*b+50*c ;
        if( sum == X)
          ans ++ ;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long mod =1000000000+7;
vector<int> a(int(1e5)+1);
int main()
{
  int n,j;
  long ans=1;
  cin>>n;
  for(int i=0;i<n;i++)
    {cin>>j;a[j]++;}
  for(int i=n-1;i>0;i-=2)
  {
  //  cout<<a[0]<<"\n";
    if(a[i]!=2) {cout<<"0\n";return 0;}
    ans = (ans*2)%mod;
      //cout<<ans<<"\n";
  }
//  cout<<ans<<"\n";
  if(n%2)
   ans*=a[0]==1;
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N;
	long[] A;

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		A = new long[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			A[i] = Long.parseLong(tokens[i]) - (long) (i + 1);
		}
		Arrays.sort(A);
		long med = getMedium();

		long result = Long.MAX_VALUE / 2;
		for (long b = med - 5; b <= med + 5; ++b) {
			result = Math.min(result, sub(b));
		}
		System.out.println(result);
	}

	long getMedium() {
		if (A.length == 1) {
			return A[0];
		} else if (A.length % 2 == 1) {
			return A[A.length / 2];
		} else {
			return (A[A.length / 2 - 1] + A[A.length / 2]) / 2;
		}
	}

	long sub(long b) {
		long result = 0;
		for (int i = 0; i < N; ++i) {
			result += Math.abs(A[i] - b);
		}
		return result;
	}

	void calc() {
	}

	void showResult() {
	}
}

Measured memory_bytes: 49876
#set
n = gets.chomp.to_i
s_arr = gets.chomp.split("")

#main
0.upto(s_arr.length - 1) do |i|
  n.times do
    if s_arr[i] == 'Z' then
      s_arr[i] = 'A'
    else
      s_arr[i].succ!
    end
  end
end

print ("#{s_arr.join}\n")

Measured memory_bytes: 2812
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[2 * n];
		for (int i = 0; i < 2 * n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int ans = 0;
		for (int i = 0; i < 2 * n; i = i + 2) {
			ans += a[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
def check_word(w,n):
    count = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                if w[i] == w[j]:
                    count += 1
            else:
                continue
    if count == 0:
        return True
    else:
        return False
    
def shiritori(w1,w2):
    if w1[len(w1)-1:len(w1)] == w2[0]:
        return True
    else:
        return False
    
n = int(input())
w = [input() for i in range(n)]
count = 0
if check_word(w,n):
    for i in range(n-1):
        if not shiritori(w[i],w[i+1]):
            print('No')
            break
        else:
            count += 1
else:
    print('No')

if count == (n-1):
    print('Yes')

Measured memory_bytes: 3064
/*
   THE DARK NIGHT RISES
I LOVE YOU 72 AND WILL FOREVER DO SO
Patience, Persistence, Perseverance, Passion, Purpose
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int N = 1e5 + 20 ;
#define F first
#define S second
# define all(v) v.begin(),v.end()          
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mk make_pair
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x)       (int)x.size()
const long long int mod=1e9 + 7;
const long double EPS=1e-12;
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )
 
const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};


 
int solve()
{
	ll n ;
	cin >> n ;
	ll sum = (n*(n+1))/2 ;
	ll a = (1+(n/3))*(n/3)*3;
	ll b = (1+(n/5))*(n/5)*5 ;
	ll c = (1+(n/15))*(n/15)*15;
	cout << sum -(a+b-c)/2 ;
	return 0 ;
    
    
}
int main()
{
    fast;
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
 
    return 0;
}
// Patience, Persistence, Perseverance, Passion, Purpose
// I LOVE YOU 72 AND WILL FOREVER DO SO.

Measured memory_bytes: 3640
a,b = map(int,input().split())
grid = [["#" if i <50 else "." for i in range(100)] for j in range(100)]
#print(grid)

white_cnt = 1
while white_cnt < a:
  grid[(white_cnt//24)*2][(white_cnt%24)*2+1] = "."
  white_cnt +=1

black_cnt = 1
while black_cnt < b:
  grid[(black_cnt//24)*2][(black_cnt%24)*2+50+1] = "#"
  black_cnt += 1  

print(100,100)
for i in range(100):
  print("".join(grid[i]))

Measured memory_bytes: 3064
function main(input) {
    new Main(input).walk();    
}
  
var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    input += chunk;
});
process.stdin.on('end', function() {
    main(input);
});
var tmp = `5
5 3 2 4 1`
class Main{
    constructor(input){
        var splits = input.split("\n");
        this.N = Number(splits[0]);
        this.A = splits[1].split(" ").map(v=>Number(v));
        this.count = 0;
    }
    walk(){
        var flag = 1;
        while(flag){
            flag = 0;
            for(var j=this.N-1; j>=1; j--){
                if(this.A[j] < this.A[j-1]){
                    this.swap(j, j-1);
                    this.count++;
                    flag = 1
                }
            }
        }
        console.log(this.A.join(" "));
        console.log(this.count);
    }
    swap(i, j){
        var tmp = this.A[i];
        this.A[i] = this.A[j];
        this.A[j] = tmp;
    }
}
// new Main(tmp).walk();


Measured memory_bytes: 15680
using System;

class E2
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int n = h[0], k = h[1];

		MInt r = 0;
		var dp = new MInt[k + 1];
		for (int i = k; i > 0; i--)
		{
			dp[i] = ((MInt)(k / i)).Pow(n);
			for (int j = 2 * i; j <= k; j += i)
				dp[i] -= dp[j];
			r += i * dp[i];
		}
		Console.WriteLine(r);
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;

	public MInt Pow(int i) => MPow(V, i);
	public override string ToString() => $"{V}";

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}


Measured memory_bytes: 28040
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

const int maxn = 55;
int c[maxn][maxn];
int dp[maxn][2 * maxn + 1];

void precalc() {
  for (int i = 0; i < maxn; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      c[i][j] = c[i - 1][j - 1];
      add(c[i][j], c[i - 1][j]);
    }
  }
  dp[1][maxn] = 1;
  dp[1][maxn + 1] = 1;
  for (int n = 2; n < maxn; n++) {
    for (int x = -n; x <= n; x++) {
      auto &cur = dp[n][maxn + x];
      for (int k = 1; k < n; k++) {
        for (int p = 0; p <= k; p++) {
          if (p < -x || (k - p) < x) {
            continue;
          }
          int y = 2 * x + p - (k - p);
          if (-maxn <= y && y <= maxn) {
            add(cur, mul(mul(c[n][k], c[k][p]), dp[n - k][maxn + y]));
          }
        }
      }
    }
  }
}

int n;

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  return true;
}

void solve() {
  printf("%d\n", dp[n][maxn]);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll n, a, b;

ll sum(ll a, ll b) {
	return (a + b + Mod) % Mod;
}
ll sub(ll a, ll b) {
	return (a - b + Mod) % Mod;
}
ll mul(ll a, ll b) {
	return (a * b) % Mod;
}
ll Pow(ll a, ll b) {
	ll res = 1;
	for (; b; b >>= 1, a = mul(a, a))
		if (b & 1) 
			res = mul(res, a);
	return res;
}
ll inv(ll x) {
	return Pow(x, Mod - 2);
}
ll calc(ll x) {
	ll res = 1;
	for (int i = n; i > n - x; i --) 
		res = mul(res, i);
	for (int i = 1; i <= x; i ++)
		res = mul(res, inv(i));
	return res;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> a >> b;
    ll ans = sub(Pow(2, n), 1);
    ans = sub(ans, calc(a));
    ans = sub(ans, calc(b));
    cout << ans << '\n';
    return (0);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  for(a;a<b+1;a++)
    {
      if(c%a==0)d++;
    }
  printf("%d\n",d);
  return 0;
}

Measured memory_bytes: 596
n = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(n):
    if A[i]<0:
        count += 1
    A[i] = abs(A[i])

ans = sum(A)
if count%2 == 1:
    ans -= 2*min(A)
print(ans)


Measured memory_bytes: 14412
from math import ceil

n = int(input())

cs = []
ss = []
fs = []

for _ in range(n-1):
    c, s, f = map(int, input().split())
    cs.append(c)
    ss.append(s)
    fs.append(f)

for i in range(n):
    t = 0
    for j in range(i, n-1):
        if t < ss[j]:
            t = ss[j]
        t = ceil(t / fs[j]) * fs[j]
        t += cs[j]
    print(t)



Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}

signed main(){
  ll x,y; cin>>x>>y;
  ll ans = 1, tmp = x*2;
  while(tmp<=y){
    ans++; tmp*=2;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double EPS= (1e-9);
using namespace std;
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=100000+9,mod=1000000000+7;
ll cnt[N],fres[N];
void go(int n){

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

       if(n%i==0){
         cnt[i]++;
         if(n/i!=i) cnt[n/i]++;
       }

   }
}
ll power(ll b,ll p){

   if(p==0) return 1;
   if((p&(1ll))){
     return b%mod*power((b*b)%mod,p/2)%mod;
   }
   else{
    return  power((b*b)%mod,p/2);
   }
}
int main(){

    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++){
        go(i);
    }
    ll ans=0;
    for(int i=k;i>=1;i--){
        fres[i]=power(cnt[i],n);
         for(int j=i*2;j<=k;j+=i){
            fres[i]=((fres[i]-fres[j])+mod)%mod;
         }
         ans+= (1ll*fres[i]*i)%mod;
         if(ans>=mod) ans-=mod;

    }
    cout<<ans<<"\n";
}



















Measured memory_bytes: 5152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc142/tasks/abc142_d>
 問題文============================================================
 =================================================================
 解説=============================================================
 公約数に合成数を選んだ場合、合成数を構成する素数個分無駄になる。
 その為、AとBの公約数のうち、素数のみを選べば最大となる。
 ================================================================
 */

void PrimeFact(ll n,map<ll,ll>& mp){
    while(n!=1){
        if(n == 2 || n == 3){
            mp[n]++; n/=n;
            continue;
        }
        bool prime_flag = false;
        for(ll i = 2;i*i <= n;i++){
            if(n%i==0){
                mp[i]++; n/=i;
                prime_flag = true;
                break;
            }
        }
        if(!prime_flag){mp[n]++; n/= n;}
    }
}
template<class Type>
Type solve(Type res = Type()){
    ll A,B; cin >> A >> B;
    ll GCD = gcd(A,B);
    map<ll,ll> mp;
    PrimeFact(GCD, mp);
    res = mp.size() + 1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

const int MAX_N = 1016;

int w, h, n;

int x1[MAX_N], x2[MAX_N], y1[MAX_N], y2[MAX_N];

void solve();

int main() {
    //freopen("0531-input.txt", "r", stdin);
    while (~scanf("%d%d", &w, &h) && (w || h)) {
        scanf("%d", &n);
        for (int i = 0; i < n; ++i) {
            scanf("%d%d%d%d", x1+i, y1+i, x2+i, y2+i);
        }
        solve();
    }
    return 0;
}

int compress(int *x1, int *x2, int w) {
    vector<int> xs;
    for (int i = 0; i < n; ++i) {
        xs.push_back(x1[i]);
        xs.push_back(x2[i]);
    }
    xs.push_back(0);
    xs.push_back(w);
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    for (int i = 0; i < n; ++i) {
        x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }
    return xs.size() - 1;
}
int fld[MAX_N + 2][MAX_N + 2];
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
void solve() {
    memset(fld, 0, sizeof(fld));
    int W = compress(x1, x2, w);
    int H = compress(y1, y2, h);
    for (int i = 0; i < n; ++i) {
        fld[y1[i]][x1[i]]++;
        fld[y2[i]][x2[i]]++;
        fld[y1[i]][x2[i]]--;
        fld[y2[i]][x1[i]]--;
    }
    // horizontal
    for (int y = 0; y < H; ++y) {
        for (int x = 1; x < W; ++x) {
            fld[y][x] += fld[y][x-1];
        }
    } 
    // vertical
    for (int x = 0; x < W; ++x) {
        for (int y = 1; y < H; ++y) {
            fld[y][x] += fld[y-1][x];
        }
    }
    /*for (int y = H - 1; y >= 0; --y) {
        for (int x = 0; x < W; ++x) {
            printf("%d ", fld[y][x]);
        }
        printf("\n");
    }*/
    int c = 0;
    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (fld[y][x]) continue;
            queue<pair<int, int> > que;
            que.push(make_pair(y, x));
            fld[y][x] = 1;
            while (que.size()) {
                int xx = que.front().second, yy = que.front().first;
                que.pop();
                for (int i = 0; i < 4; ++i) {
                    int nx = xx + dx[i], ny = yy + dy[i];
                    if (nx < 0 || nx >= W || ny < 0 || ny >= H || fld[ny][nx]) continue;
                    fld[ny][nx] = 1;
                    que.push(make_pair(ny, nx));
                }
            }
            ++c;
        }
    }
    printf("%d\n", c);
}

Measured memory_bytes: 6772
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        int a = sc.nextInt();
        pw.println(a + a * a + a * a * a);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 35788