akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    long long int n,k;
    cin>>n>>k;
    vector<long long int> v;
    rep(i,n){
        long long int enter;
        cin>>enter;
        v.push_back(enter);
    }
    sort(all(v));
    long long int ans=0;
    if(n-k<=0) cout<<0<<endl;
    else{
        rep(i,n-k){
            ans+=v[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2420
N = (gets).to_i
A = (gets).to_i
B = (gets).to_i
C = (gets).to_i
D = (gets).to_i
E = (gets).to_i

pas = [N,0,0,0,0,0]
loc = [0,A,B,C,D,E]
count = 0
#p pas
#p loc

def cut(x,a)
    return x<=a ? x : a
end

=begin
while pas[5] < N
    5.downto(1) do |n|
        next if pas[n-1] <= 0
        pa = cut(pas[n-1], loc[n])
        pas[n] = pas[n] + pa
        pas[n-1] = pas[n-1] - pa
    end
    #p pas
    count = count + 1
end
* 単純な話、ボトルネックですべての性能が決まるから、そこで
  計算してしまえば良い気がする
=end

nek = loc[1..5].min
q,r = N.divmod(nek)
base_time = q + (r==0 ? 0 : 1)

count = base_time + 4

puts count

Measured memory_bytes: 1916
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n,u,v;
	cin >> n >> u >> v;
	u--,v--;

	vector<vector<int>> e(n);
	for(int i = 0;i < n-1;i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	vector<int> d1(n,INF);

	queue<int> que;
	d1[u] = 0;
	que.push(u);
	while(que.size()){
		int now = que.front();
		que.pop();

		for(int next:e[now]){
			if(d1[next] > d1[now] + 1){
				d1[next] = d1[now] + 1;
				que.push(next);
			}
		}
	}

	vector<int> d2(n,INF);
	d2[v] = 0;
	que.push(v);
	while(que.size()){
		int now = que.front();
		que.pop();

		for(int next:e[now]){
			if(d2[next] > d2[now] + 1){
				d2[next] = d2[now] + 1;
				que.push(next);
			}
		}
	}

	int d2_max = 0;
	for(int i = 0;i < n;i++){
		if(d1[i] < d2[i] && d2[i] > d2_max){
			d2_max = d2[i];
		}
	}

	cout << d2_max-1 << endl;
}


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

using namespace std;
 
int main() {
    int n,temp,a,b,c;
    int result = 0;
    cin >> n;
    vector<int> l;
    for(int i=0;i<n;i++){
        cin >> temp;
        l.insert(l.begin(),temp);
    }
    sort(l.begin(),l.end());
    for(int i=0;i<n-2;i++){
        auto l_itr = l.end();
        l_itr--;
        l.erase(l_itr);
        a = *l_itr;
        for(int j=0;j<l.size()-1;j++){
            l_itr--;
            b = *l_itr;
            temp = a-b;
            auto l2_itr=upper_bound(l.begin(),l.end(),temp);
            temp = distance(l2_itr,l_itr);
            if(temp<0){
                temp=0;
            }
            result+=temp;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  string s;
  cin >> s;
  
  int ans = 100000;
  for(int i = 0; i < s.size(); i++) {
    string t = s.substr(i,3);
    int tmp = stoi(t);
    if(tmp >= 753) {
      tmp = tmp - 753; 
    } else {
      tmp = 753 - tmp; 
    }
    if(tmp >= 0) {
      ans = min(ans,tmp);
    }
  }
  cout << ans << endl;
}

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

int main() {
    int N; cin >> N;
    string s = "";
    while(N != 0){
        if(N % -2 == 0){
            s = "0" + s;
        } else {
            s = "1" + s;
            N--;
        }
        N /= -2;
    }
    if(s == ""){
        s = "0";
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
int main(void){     
    int n,taro=0,hanako=0,i;   
    char s1[1000],s2[1000];   
    scanf("%d",&n);     
    for(i=0;i<n;i++){             
        scanf("%s %s",s1,s2);            
        if(strcmp(s1,s2)==0){                     
            taro++;                     
            hanako++;            
        }       
        else if(strcmp(s1,s2)<0){               
                hanako+=3;           
            }           
        else{               
                taro+=3;          
            }       
        }
    printf("%d %d\n",taro,hanako);
    return 0;
    }


Measured memory_bytes: 2104
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,q,l,r;
    cin>>n>>q;
    string s;
    cin>>s;
    ll dp[N];
    dp[1]=0;
    rep(i,1,n-1){
        if(s[i]=='C' && s[i-1]=='A') dp[i+1]=(dp[i]+1);
        else dp[i+1]=dp[i];
    }
    // rep(i,1,n) cout<<dp[i]<<" ";
    rep(i,0,q-1){
        cin>>l>>r;
        // l--;r--;
        cout<<dp[r]-dp[l]<<endl;
    }
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 1872
/*#include <bits/stdc++.h>
using namespace std;
int main(){
	int n , m ;
	scanf("%d%d",&n,&m);
	int x , y , t;
	for( int i = 0 ; i < m ; i++ ){
		scanf("%d%d%d",&x,&y,&t);
		
	}
	return 0;
}*/

#include <bits/stdc++.h>
using namespace std;
const int AX = 100+6;
map<string ,int >mp;
int mp2[AX];
int main(){
	int n , m;
	cin >> n ;
	string s;
	int tot = 1;
	memset(mp2, 0 , sizeof(mp2));
	for( int i = 0 ; i < n ; i++ ){
		cin >> s;
		int tmp;
		if( mp[s] ) tmp = mp[s];
		else {
			tmp = tot;
			mp[s] = tot ++;
		}
		mp2[tmp] ++;
	}
	cin >> m;
	for( int i = 0 ; i < m ; i++ ){
		cin >> s;
		int tmp;
		if( mp[s] ) tmp = mp[s];
		else {
			tmp = tot;
			mp[s] = tot ++;
		}
		mp2[tmp] --;
	}
	int ibest = 0;
	for( int i = 1 ; i < tot ; i++ ){
		ibest = max( ibest , mp2[i] ) ; 
	}
	cout << ibest << endl;
	return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int f(int n){
    if(n&1)
        return (3 * n + 1);
    else
        return n / 2;
}

int main(){
  FAST();

  int s;
  cin >> s;
  set<int> abc;
  abc.insert(s);

  while(true){
      s = f(s);
      if(abc.find(s) == abc.end()){
        abc.insert(s);
      }
      else{
        cout << abc.size() + 1 << endl;
        break;
      }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//ll gcd(ll x, ll y){ return y ? gcd(y, x%y): x;}
//ll lcm(ll x, ll y){ return x*y/gcd(x, y);}
int main(){
  ll A, B;
  cin >> A >> B;
  ll g = __gcd(A,B);
  ll s = g;
  ll ans = 1;
  for(ll i=2; i*i<=s; i++){
    if(g%i==0){
      ans+=1;
      while(g%i==0){
        g/=i;
      }
    }
  }
  if(g>1){
    ans++;
  }
  cout << ans;
  
}

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

int main() {
	
    long long n;
    cin>>n;
    double p[n+1];
    double dp[n+1][n+1];
    for(long long i=1;i<n+1;i++){
        cin>>p[i];
    }
    for(long long i=0;i<=n;i++){
        for(long long j=0;j<=i;j++){
            if(!i){
                dp[i][j]=1;
                continue;
            }dp[i][j]=0;
            if(i!=j)
            dp[i][j]+=dp[i-1][j]*(1.0-p[i]);
            
            if(j-1>=0){
                dp[i][j]+=dp[i-1][j-1]*p[i];
            }
        }
    }double ans=0.0;
    for(long long i=n/2+1;i<=n;i++){
        ans+=dp[n][i];
    }cout<<setprecision(100)<<ans;
}


Measured memory_bytes: 70144
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>

using namespace std;

int main()
{
	long long int n;
	cin >> n;
	long long int s[5];
	cin >> s[0];
	long long int m = s[0];
	for (long long int i = 1; i < 5; i++)
	{
		cin >> s[i];
		
		if (m > s[i])
		{
			m = s[i];
			}

		
	}
	
	long long int x = 0;
	if (n % m == 0)
	{
		x = n / m;
	}
	else
	{
		x = n / m + 1;
	}
	cout << x + 4 << endl;

}

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

int main()
{
  int N;
  std::string S;
  std::cin >> N;
  std::cin >> S;
  int cnt = 0;
  int mode = 0;
  for (int i=0; i<N; i++) {
    switch (mode) {
      case 0:
        if (S[i] == 'A') mode = 1;
        break;
      case 1:
        if (S[i] == 'B') mode = 2;
        else if (S[i] != 'A') mode = 0;
        break;
      case 2:
        if (S[i] == 'A') mode = 1;
        else {
          if (S[i] == 'C') cnt++;
          mode = 0;
        }
        break;
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MAX_N = 55;
const ll INF = 1e15;
ll C[MAX_N],D[MAX_N],t[MAX_N*MAX_N*50];
priority_queue<P, vector<P>, greater<P> > Q;

void init()
{
	rep(i,MAX_N*MAX_N*50)
	{
		t[i] = INF;
	}
	return;
}

struct edge
{
	ll to, cost, time;
};

vector<edge> G[MAX_N];

struct edge2
{
	ll to, time;
};

vector<edge2> G2[MAX_N*MAX_N*50];

int main()
{
	ll n,m,s;
	cin >> n >> m >> s;
	rep(i,m)
	{
		ll u,v,a,b;
		cin >> u >> v >> a >> b;
		u--; v--;
		/*
		edge e;
		e.to = v; e.cost = a, e.time = b;
		G[u].push_back(e);
		e.to = v;
		G[v].push_back(e);
		*/
		int temp = a;
		while(temp <= MAX_N*50)
		{
			edge2 e2;
			e2.to = (temp-a)*n+v; e2.time = b;
			G2[temp*n+u].push_back(e2);
			e2.to = (temp-a)*n+u;
			G2[temp*n+v].push_back(e2);
			temp++;
		}
	}
	rep(i,n)
	{
		cin >> C[i] >> D[i];
		rep(j,MAX_N*50)
		{
			edge2 e2;
			e2.time = D[i];
			if (j+C[i] > MAX_N*50) e2.to = n * MAX_N * 50 + i;
			else e2.to = n*(j+C[i]) + i;
			G2[i+j*n].push_back(e2);
		}
	}

	init();
	s = min(s,ll(MAX_N*50));
	t[s*n] = 0;
	Q.push(P(0,s*n));
	while(!Q.empty())
	{
		P p = Q.top(); Q.pop();
		ll v = p.second;
		if (t[v] < p.first) continue;
		rep(i,G2[v].size())
		{
			edge2 e = G2[v][i];
			if (t[e.to] > t[v] + e.time)
			{
				t[e.to] = t[v] + e.time;
				Q.push(P(t[e.to], e.to));
			}
		}
	}

	rep(i,n-1)
	{
		ll ans = INF;
		rep(j,MAX_N*50+1)
		{
			ans = min(ans,t[j*n+i+1]);
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    map<string, int> votes;
    int n; cin >> n;

    int max_value = 0;

    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        votes[s]++;

        max_value = max(max_value, votes[s]);
    }

    for (auto it : votes) {
        if (it.second == max_value) 
            cout << it.first <<  endl;
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}

int main()
{
    int n;
    cin >> n;
    vector<ll> dp(n + 1, 2);
    dp[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int j = i * 2; j <= n; j += i)
        {
            dp[j]++;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += i * dp[i];
    }
    cout << ans;
}

Measured memory_bytes: 81344
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  string s; cin >> s;
  
  rep(i,3){
    cout << s[i];
  }
  
  cout << endl;
  
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int[] a = new int[N];
        for (int i = 0 ; i < N ; i++) {
            a[i] = scanner.nextInt();
        }

        int count = 0;
        int current = 1;
        for (int i = 0 ; i < N ; i++) {
            if (a[i] == current) {
                current++;
            } else {
                count++;
            }
        }

        if (current == 1) {
            System.out.println(-1);
        } else {
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 59428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) return 0;
        
        vector<int> A(N);
        for(int i=0;i<N;i++) cin>>A[i];
        sort(all(A));
        
        ll sum=0;
        
        for(int i=1;i<N-1;i++) sum+=A[i];
        cout<<sum/(N-2)<<endl;
    }
}



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

typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  ll n;
  cin >> n;
  ll ans = n * (n - 1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;

signed main(){
	string s, t; cin >> s;
	t = s; reverse(t.begin(), t.end());
	int ans = 0;
	for(int i = 0; i < s.size(); i++) if(s[i] != t[i]) ans++;
	cout << ans/2 << endl;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	int n,m;cin>>n>>m;
	if(n>m)n=m;
	int x[m];rep(i,m)cin>>x[i];
	sort(x,x+m);
	vint kai;rep(i,m-1)kai.pb(x[i+1]-x[i]);
	sort(rall(kai));
	rep(i,n-1)kai[i]=0;
	int ans=0;
	fh(p,kai)ans+=p;
	dans;
}





Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll ans = 1ll;
    rep(i, N)
    {
        ll T;
        cin >> T;
        ans = lcm(ans, T);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int w[10];
	rep(i, 0, 5) if (next<int>() == 0) cout<<i+1<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 3532
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let Read3Int () = ReadNextInt (), ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ARC077 =
    let private Mod = 1000000007L

    let private Pushpush () =
        let n = ReadNextInt ()
        let r = Array.zeroCreate n
        let rec loop i j b = function
            | [] ->
                System.String.Join(" ", r |> Seq.map (fun c -> c.ToString()))
                |> printfn "%s"
            | h :: t ->
                r.[if b then i else j] <- h
                let ni, nj = if b then i + 1, j else i, j - 1
                loop ni nj (not b) t
        ReadListOf int n
        |> List.rev
        |> loop 0 (n - 1) true

    let Entry = Pushpush

ARC077.Entry ()

Measured memory_bytes: 51744
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        int int4 = Integer.parseInt(scan.next());
//        double db = Double.parseDouble(scan.next());
        int ans_int = 0;
        String ans = "";
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < int1; i++){
            int m = Integer.parseInt(scan.next());
            if(m>=int2){
                list.add(m);
            }
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(list.size());
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 47736
// Last Change:                       11/19/2018 16:03:29.
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

struct Process {
  string name;
  int time;
};

int main() {
  int N, Q;
  Process input;
  queue<Process> q;
  int currentTime = 0;

  cin >> N >> Q;

  for (int i = 0; i < N; i++) {
    cin >> input.name >> input.time;
    if (input.time <= Q) {
      currentTime += input.time;
      cout << input.name << " " << currentTime << "\n";
    } else {
      currentTime += Q;
      input.time -= Q;
      q.push(input);
    }
  }
  Process a;
  while (!q.empty()) {
    a = q.front();
    q.pop();
    if (a.time <= Q) {
      currentTime += a.time;
      cout << a.name << " " << currentTime << "\n";
    } else {
      currentTime += Q;
      a.time -= Q;
      q.push(a);
    }
    cout << flush;
  }
}




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

int main()
{
	string N;
	cin >> N;
	ll temp = 0;
	rep(i,N.size())
	{
		temp = temp + (N[i] - '0');
	}
	if (temp % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl; 
	return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  
  int n = s.size();
  bool ok = false;
  if(s == t) ok = true;
  rep(i,n){
    s = s[n-1] + s.substr(0,n-1);
    if(s == t) ok = true;
  }
  
  cout << ( ok ? "Yes" : "No" ) << endl;
  
  return 0;
}
                      
                      

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N;
	int n = 0,i = 0;
	char S[50];
	scanf("%d%s",&N,&S);
	while (i+2<=49) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C' ) {
			n++;
		}
		i++;
	}
	printf("%d",n);
	return 0;
}

Measured memory_bytes: 128
X,Y = map(int,input().split())

a = (Y - 2 * X ) / 2
yMod = Y % 2
b = X - a
if yMod == 0:
  if a >= 0 and b >= 0 and (a != 0 or b != 0):
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 9192
import collections
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

one = 0
theo = 0
skip = False
for i in range(N-1):
    if skip:
        skip = False
        continue
    if A[i] == A[i+1]:
        if one == 0:
            one = A[i+1]
            skip = True
        else:
            theo = A[i+1]
            break
print(one*theo)

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

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t[i];
  }

  map<string, int> ma;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ma[s[i]] = 0;
  }
  for (int i = 0; i < m; i++) {
    ma[t[i]] = 0;
  }
  for (int i = 0; i < n; i++) {
    ma[s[i]]++;
  }
  for (int i = 0; i < m; i++) {
    ma[t[i]]--;
  }
  for (int i = 0; i < n; i++) {
    ans = max(ans, ma[s[i]]);
  }
  for (int i = 0; i < m; i++) {
    ans = max(ans, ma[t[i]]);
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i%3==0 || i%5==0){
			continue;
		}
		else{
			sum+=i;
		}
	}
	cout<<sum;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

vector<int> _16nums;

class AOJ1154{
private:
  int n;
  vector<int> vec;
public:
  AOJ1154(int n):n(n){
    vec.clear();
  }
  ~AOJ1154(){}

  
  int getFactor(int key,int pos){
    int pre = -1;
    for(int i = 1;i<=310000;i++){
      if((i%7 == 1 || i%7 == 6) && key >= _16nums[pos]*i){
	pre = i;
      }
      else if(!(i%7 == 1 || i%7 == 6)){}
      else break;
    } 
  
    return pre;
  }
  

  void run(){
    int pre = n;
    for(int i=1;i<_16nums.size();i++){
      if(pre%_16nums[i] == 0){
	int fact = getFactor(pre,i);
	if(fact == -1)continue;
	bool con = false;
	for(int j=0;j<vec.size();j++){
	  if(_16nums[i]%vec[j] == 0){
	    con = true;
	    break;
	  }
	}
	if(con)continue;
	vec.pb(_16nums[i]);
      }
    }
  

  print();
  }

    void print(){
      cout << n << ":";
      for(int i=0;i<vec.size();i++){
	cout << ' ' << vec[i];
      }
      cout << endl;
    }
  

};

void create16nums(){
  
  for(int i=1;i<310000;i++){
    if(i%7 == 1 || i%7 == 6){
      _16nums.pb(i);
    }
  }

}

int main(){
  create16nums();
  while(true){
    int N;
    cin >> N;
    if(N == 1)break;
    AOJ1154 ans = AOJ1154(N);
    ans.run();
  }

return 0;
}

Measured memory_bytes: 1592
s = input()
q = int(input())
query = [input().split() for _ in range(q)]

from collections import deque
ans = deque(list(s))
flip = 0

for i in range(q):
    # print(ans, flip)
    _query = query[i]
    if len(_query) == 1:
        flip = 1 - flip
    else:
        if _query[1] == '1':
            if flip:
                ans.append(_query[2])
            else:
                ans.appendleft(_query[2])
        else:
            if not flip:
                ans.append(_query[2])
            else:
                ans.appendleft(_query[2])

if not flip:
    print(''.join(ans))
else:
    print(''.join(list(ans)[::-1]))


Measured memory_bytes: 46180
#include<iostream>

using namespace::std;

int fib(int n) {
	


	int x[100];
	x[0] = 0;
	x[1] = 1;
	x[2] = 2;
	x[3] = 4;

	for (int i = 4; i <= n; i++) {
		x[i] = x[i - 3] + x[i - 2] + x[i - 1];
	}
	return x[n];
}


int main() {
	/*int n;
	cin >> n;
	int ans;
	int ama;

	ans = n / 3;
	ans = ans * 4;

	if (n % 3 == 1) {
		ans +=
	}
	else if (n % 3 == 2) {

	}*/
	int a[100];
	int i= 0;

	while (true) {
		cin >>a[i];
		if (a[i] == 0)
			break;
		i++;
	}

	for (int j = 0; j < i; j++) {
		if (a[j] != 0) {
			cout << fib(a[j])/10/ 365 + 1 << endl;
		}
		else {
			cout <<0<<endl;
		}
	}

	return 0;

}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    //ll P , Q , R;
    //cin >> P >> Q  >> R;
    ll A, P;
    cin >> A >> P;
    ll sum = (A * 3 + P) / 2;

    cout << sum << endl;

} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int cnt=0, maxcnt=0;
    for (int i=0; i<s.length(); i++) {
        if (s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') {
            cnt++;
            maxcnt = max(maxcnt, cnt);
        } else {
            cnt = 0;
        }
    }
    cout << maxcnt << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   cout << setprecision(10) << fixed;
   if(n%2==0){
      cout << "0.5\n";
   }else{
      double ans = (n+1)/2;
      ans = ans/n;
      cout << ans << '\n';
   }
   return 0;
} 

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

int n,a=0,b=1,cnt[200005];string s[200005],m;

int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    
    //for(int i=0;i<n;i++)cout<<s[i]<<" ";
    
    m=s[0];
    for(int i=1;i<n;i++){
        if(s[i]!=m){
            m=s[i];
            cnt[a]=b;
            a++;
            b=1;
        }else{
            b++;
        }
    }
    cnt[a]=b;
    sort(cnt,cnt+a+1);
    
    //for(int i=0;i<a+1;i++)cout<<cnt[i]<<" ";
    //cout<<a<<endl;
    
    int y=cnt[a],k=1;
    if(y==1)cout<<s[0]<<endl;
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i])k++;
        else k=1;
        if(k==y)cout<<s[i]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cin>>m;
    string t[m];
    for(int i=0;i<m;i++){
        cin>>t[i];
    }

    int ans=0;
    for(int i=0;i<n;i++){
        int mon=0;
        for(int j=0;j<n;j++){
            if(s[i]==s[j]) mon++;
        }
        for(int j=0;j<m;j++){
            if(s[i]==t[j]) mon--;
        }
        ans=max(ans,mon);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <utility>
#ifndef LIB_REPEAT_HPP
#define LIB_REPEAT_HPP
#define repeat(i,n) for (int i = 0; i < (n); ++i)
#define repeat_from(i,m,n) for (int i = (m); i < (n); ++i)
#define repeat_one(i,n) for (int i = 1; i <= (n); ++i)
#define repeat_rev(i,n) for (int i = (n)-1; 0 <= i; --i)
#define foreach(it, cont) for (decltype(cont.begin()) it = cont.begin(); it != cont.end(); ++it)
#endif
using namespace std;
typedef int tribool;
string s;
int p, q, r;
tribool tri_negate(tribool x) {
    static const tribool table[3] = { 2, 1, 0 };
    return table[x];
}
tribool tri_mult(tribool x, tribool y) {
    static const tribool table[3][3] =
        { { 0, 0, 0 }
        , { 0, 1, 1 }
        , { 0, 1, 2 }
        };
    return table[x][y];
}
tribool tri_plus(tribool x, tribool y) {
    static const tribool table[3][3] =
        { { 0, 1, 2 }
        , { 1, 1, 2 }
        , { 2, 2, 2 }
        };
    return table[x][y];
}
std::pair<tribool,int> eval(int i) {
    switch (s[i]) {
        case '0':
        case '1':
        case '2':
            return make_pair(s[i]-'0',i+1);
        case 'P':
            return make_pair(p,i+1);
        case 'Q':
            return make_pair(q,i+1);
        case 'R':
            return make_pair(r,i+1);
        case '-': {
            std::pair<tribool,int> p = eval(i+1);
            return make_pair(tri_negate(p.first),p.second);
        }
        case '(': {
            std::pair<tribool,int> a = eval(i+1);
            char op = s[a.second];
            std::pair<tribool,int> b = eval(a.second+1);
            // consume ')'
            switch (op) {
                case '*':
                    return make_pair(tri_mult(a.first,b.first),b.second+1);
                case '+':
                    return make_pair(tri_plus(a.first,b.first),b.second+1);
                default:
                    assert(false);
            }
        }
        default:
            assert(false);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    while (true) {
        cin >> s;
        if (s == ".") break;
        int cnt = 0;
        repeat (i,27) {
            p = i/9;
            q = (i/3)%3;
            r = i%3;
            if (eval(0).first == 2) {
                cnt += 1;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
#define P(a,b) make_pair(a,b)
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"in%s.txt",s);
	freopen(str,"r",stdin);
//	sprintf(str,"out%s.txt",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=200010,Inf=1000000000;
const double A=4.292036732051033807686783083602,B=11.415926535897932384626433832795;
pii a[N];
int x1,y1,x2,y2,n,b[N],s[N];
int main()
{
	x1=rd(),y1=rd(),x2=rd(),y2=rd();n=rd();
	int t=1,ans=0,m=0;
	if(x1>x2)swap(x1,x2),swap(y1,y2);
	if(y1>y2)y1=-y1,y2=-y2,t=-1;
	fo(i,1,n){
		int x=rd(),y=rd()*t;
		if(x1<=x&&x<=x2&&y1<=y&&y<=y2)a[++m]=P(x,y),b[m]=y;
	}
	sort(a+1,a+m+1);
	sort(b+1,b+m+1);int nn=unique(b+1,b+m+1)-b-1;
	fo(i,1,m)a[i].second=lower_bound(b+1,b+nn+1,a[i].second)-b-1,s[i]=Inf;
	fo(i,1,m){
		int cur=upper_bound(s+1,s+m+1,a[i].second)-s;
		ans=max(ans,cur);
		s[cur]=min(s[cur],a[i].second);
	}
	db res=0;
	res=100.*(x2-x1+y2-y1);
	if(min(y2-y1+1,x2-x1+1)==ans)res+=B,ans--;
	res-=ans*A;
	printf("%.12Lf",res);
	return 0;
}

Measured memory_bytes: 3328
N = int(input())
A = list(map(int, input().split()))
ruisekiwa = [0]
MOD = 10**9+7
for i in reversed(range(N)):
    ruisekiwa.append((ruisekiwa[-1]+A[i])%MOD)
ruisekiwa.reverse()
ruisekiwa = ruisekiwa[1:]
ans = 0
for i in range(N):
    ans += (A[i]%MOD)*ruisekiwa[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 103604
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	hs := make([]int,n)

	for i := 0; i < n; i++ {
		var h int
		fmt.Scan(&h)
		hs[i] = h
	}

	count := 1

	LABEL:
	for i := 1; i < n; i++ {
		for j := 0; j < i; j++ {
			if hs[i] < hs[j] {
				continue LABEL
			}
		}
		count++
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD=1e9+7;
#define endl '\n'
#define F first
#define S second
const double PI = 3.141592653589793238460;
 
  void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
    #endif
}


int  main()
{
  c_p_c();
  ll n;cin>>n;
  ll a[n+1];
  for(ll i=1;i<=n;i++)cin>>a[i];
    ll sum=0;

  for(ll i=1;i<n;i++)
  {
    if(a[i]>a[i+1])
    {
      sum+=a[i]-a[i+1];
      a[i+1]=a[i];
    }
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 5164
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

	int t = n / 1000;

	if (t * 1000 < n)
	{
		cout << (t + 1) * 1000 - n;

	}
	else if (t * 1000 == n)
	{
		cout << 0 << endl;
	}


	return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

inline
ll gcd(ll a, ll b)
{
    if (a < b) swap(a, b);
    if (b == 0){
        return a;
    }else{
        return gcd(b, a % b);
    }
}

int main()
{
    scanInt(N);
    scanVecLLInt(T, N);
    ll lcm = 1;
    loop(i, N){
        ll temp = gcd(lcm, T[i]);
        lcm = temp * (lcm / temp) * (T[i] / temp);
    }
    printf("%lld\n", lcm);
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

total = sum(B)
memo = 20
for i in A:
    if memo+1 == i:
        total += C[i-2]
    memo = i

print(total)


Measured memory_bytes: 8940
import sys
input = sys.stdin.readline

n, m, l = map(int, input().split())
INF = float("inf")

def warshall_floyd(d, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

d = [[INF for i in range(n)] for j in range(n)]
for i in range(n): d[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    a -= 1; b -= 1
    d[a][b] = c
    d[b][a] = c
d = warshall_floyd(d, n)

d2 = [[INF for i in range(n)] for j in range(n)]
for i in range(n):
    for j in range(n):
        if d[i][j] <= l: d2[i][j] = 1
    d2[i][i] = 0
d2 = warshall_floyd(d2, n)

q = int(input())
for _ in range(q):
    s, t = map(int, input().split())
    res = d2[s-1][t-1]
    print(-1 if res == INF else res-1)


Measured memory_bytes: 128604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,k;
    cin>>a>>b>>k;
    if(k>=a)
    {

        k=k-a;
        a=0;
        b=b-k;
        if(b<0) b=0;
        cout<<a<<" "<<b<<endl;
    }
    else{
        a-=k;
        cout<<a<<" "<<b<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
//*
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;
	ll a, b, c, d;
	string s;
	ll take[2] = {2, 0};
	char op[2] = { '-', '+' };

	cin >> n;

	d = n % 10;
	c = (n - d) / 10 % 10;
	b = (n - c * 10 - d) / 100 % 10;
	a = (n - b * 100 - c * 10 - d) / 1000;

	ll sum = a + b + c + d;

	REP(i, 2) {
		REP(j, 2) {
			REP(k, 2) {
					ll x = sum - b * take[i] - c * take[j] - d * take[k];
					if (x == 7) {
						cout << a << op[i] << b << op[j] << c << op[k] << d << "=7" << endl;
						return 0;
					}
			}
		}
	}
}
//*/

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn rec(l: usize, r: usize, seq: &[usize], memo: &mut Vec<Vec<Option<usize>>>) -> usize {
    if r - l < 2 {
        return 0;
    }

    if let Some(res) = memo[l][r] {
        return res;
    }

    if (seq[l] as i64 - seq[r - 1] as i64).abs() <= 1 {
        if rec(l + 1, r - 1, seq, memo) + 2 == r - l {
            let res = r - l;
            memo[l][r] = Some(res);
            return res;
        }
    }

    let mut res = 0;
    for c in l + 1..r {
        res = max(res, rec(l, c, seq, memo) + rec(c, r, seq, memo));
    }

    memo[l][r] = Some(res);
    res
}

fn main() {
    loop {
        let n = get!(usize);

        if n == 0 {
            break;
        }

        let ws = util::gets();

        let mut memo = vec![vec![None; n + 1]; n + 1];
        println!("{}", rec(0, n, &ws, &mut memo));
    }
}



Measured memory_bytes: 5076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int tem=0;
		while(sc.hasNext()) {
			int n = sc.nextInt();
			for(int i=9;i>=0;i--) {
				for(int j=9;j>=0;j--) {
					for(int k=9;k>=0;k--) {
						for(int l=9;l>=0;l--) {
							if(i+j+k+l == n)  tem+=1;
						}
					}
				}
			}

			System.out.printf("%d\n",tem);
			tem=0;
		}
	}
}




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

int main()
{
	int A,B,i,N,flag=0;
  	cin>>N;
  	cin>>A>>B;
  	for(i=A;i<=B;i++)
    {
      if(i%N==0)
      {
      	flag=1;
        break;
      }
    }
  	if(flag==1)
    {
    	cout<<"OK"<<endl;
    }
  else
  {
  	cout<<"NG"<<endl;
  }


	return 0;
}

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

int main(){
 int p, q, r;
  cin >> p >> q >> r;
  cout << (p + q + r) - max({p, q, r}) << endl;
}


Measured memory_bytes: 256
import math
A,B,h,m=map(int,input().split())
time=60*h+m
a=(0.5*time)%360
b=(6*time)%360
x=abs(a-b)
if x==0 or x==360:
  c=abs(A-B)
elif x==180:
  c=A+B
else:
  c=math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(x)))
print(c)

Measured memory_bytes: 9452
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define mod 1000000007
typedef long long ll;
using namespace std;

double x[10],y[10];

double dist(int i,int j){
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx*dx + dy*dy, 0.5);
}

int main(){
  int N; cin >> N;
  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i];
  }
  vector<int> v(N);
  for(int i=0;i<N;i++) v[i] = i;
  double sum = 0;
  do{
    for(int i=0;i<N-1;i++){
      sum += dist(v[i],v[i+1]);
    }
  }while(next_permutation(v.begin(),v.end()));
  double fac = 1.0;
  for(int i=2;i<=N;i++) fac = fac * i;
  printf("%.20f\n", sum/fac);
  return 0;
}
        
  

Measured memory_bytes: 384
import sys
import numpy as np
 
n = int(input())
lst = [int(i) for i in sys.stdin.readline().split()]
arr = np.array(lst, np.int64)
mod = 10 ** 9 + 7
s = 0

for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    s += 2 ** i * c1 * (n - c1)
    arr >>= 1
print(s % mod)

Measured memory_bytes: 48768
#include <cstdio>

using namespace std;

int main()
{
    int x;
    scanf("%d", &x);

    int p = 0;
    for (int i = 1;; ++i) {
        p += i;
        if (p >= x) {
            printf("%d\n", i);
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 888