akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using ll = long long;
struct node {
    ll to;
    ll weight;
};
using graph = std::vector<std::vector<node>>;
constexpr ll infty=-1e15;
void reachable(const graph &g, int s, bool flg[]){
    std::queue<int> qu;
    for(int i=0;i<(int)g.size();i++)flg[i]=false;
    qu.push(s);
    while(!qu.empty()){
        int i=qu.front();
        qu.pop();
        if(flg[i])continue;
        flg[i]=true;
        for(auto &v:g[i]){
            if(flg[v.to])continue;
            qu.push(v.to);
        }
    }
}
bool from_start[2500];
bool to_goal[2500];
bool relaxing(const graph &g, ll l[]){
    bool relaxed=false;
    for(int i=0;i<(int)g.size();i++){
        if(l[i]==infty || !from_start[i] || !to_goal[i])continue;
        for(int j=0;j<(int)g[i].size();j++){
            if(l[g[i][j].to]<l[i]+g[i][j].weight){
                l[g[i][j].to]=l[i]+g[i][j].weight;
                relaxed=true;
            }
        }
    }
    return relaxed;
}
ll l[2500];
int main(){
    int n,m,p;
    scanf("%d%d%d",&n,&m,&p);
    graph g(n);
    graph g_rev(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        g[a-1].push_back({b-1,c-p});
        g_rev[b-1].push_back({a-1,1});
    }
    reachable(g,0,from_start);
    reachable(g_rev,n-1,to_goal);
    for(int i=0;i<n;i++)l[i]=infty;
    l[0]=0;
    for(int cnt=0;cnt<=m;cnt++){
        if(!relaxing(g,l))break;
    }
    if(relaxing(g,l)){
        printf("-1\n");
    }else{
        printf("%lld\n",std::max(0LL,l[n-1]));
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    ll A, B, N;
    cin >> A >> B >> N;

    ll Min = min(B,N);
    if(Min == B) Min--; 

    ll ans = A*(Min) / B;
    cout << ans << endl;


}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;


int main() {
  int n; cin >> n;
  int buf[100] = {};
  for(int i = 2; i <= n; i++) {
    int x = i;
    while(x > 1) {
      int div;
      for(int j = 2; j <= x; j++) {
        if (x % j == 0) {
          div = j;
          break;
        }
      }
      buf[div]++;
      x /= div;
    }
  }

  long long dp[100] = {};
  dp[1] = 1;
  for(int i = 2; i <= n; i++) {
    for(int j = 75; j >= 1; j--) {
      for(int k = 75; k >= 2; k--) {
       if (j * k > 75 || 75 % (j * k) != 0) continue;
       if (buf[i] < k - 1) continue;
       dp[j * k] += dp[j];
      }
    }
  }
  cout << dp[75] << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>
#include<climits>
#include<iomanip>
#include<vector>
#include<deque>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX_LEN 16
#define MAX_STATE (1<<16)

using namespace std;
typedef pair<int,int> ii;

const int DIFF = 3;
int N,H[MAX_LEN],W[MAX_LEN];
int bitmask[MAX_LEN][12][12][3][2]; // bitmask[][][][i] i = false -> erase , true -> insert
bool mincost[MAX_STATE];
char G[4][4];
char color[] = {'R','G','B'};

inline void makeBitMask(){
  REP(y,-3,8){
    REP(x,-3,8){
      rep(stamp,N){
	rep(c,3){
	  rep(cy,H[stamp]){
	    rep(cx,W[stamp]){
	      int nx = x + cx;
	      int ny = y + cy;
	      if( !( 0 <= nx && nx < 4 && 0 <= ny && ny < 4 ) )continue;
	      if( G[ny][nx] == color[c] )bitmask[stamp][y+DIFF][x+DIFF][c][true]  |= (1<<(nx+(ny*4)));
	      else                       bitmask[stamp][y+DIFF][x+DIFF][c][false] |= (1<<(nx+(ny*4)));
	    }
	  }
	}
      }
    }
  }
}

void compute(){
  for(bool& i : mincost)i = false;
  mincost[0] = true;
  deque<ii> deq;
  deq.push_back(ii(0,0));
  while(!deq.empty()){
    ii data = deq.front(); deq.pop_front();

    if( data.first == (MAX_STATE-1) ){
      cout << data.second << endl;
      break;
    }

    rep(stamp,N){
      rep(col,3){
	REP(y,-3,8){
	  REP(x,-3,8){
	    int state = ( data.first | bitmask[stamp][y+DIFF][x+DIFF][col][true] ) & (~bitmask[stamp][y+DIFF][x+DIFF][col][false]);
	    if(mincost[state])continue;
	    mincost[state] = true;
	    deq.push_back(ii(state,data.second+1));
	  }
	}
      }
    }

  }
}

int main(){
  cin >> N;
  rep(i,N)cin >> H[i] >> W[i];
  rep(y,4)rep(x,4)cin >> G[y][x];

  makeBitMask();

  compute();

  return 0;
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int a,b,t;cin>>a>>b>>t;
  cout<<(t/a)*b<<endl;
 

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
void solve(){
    int n,k;
    cin>>n>>k;
    int d;int x;set<int>s;
    for(int i=0;i<k;i++){
        cin>>d;
        for(int j=0;j<d;j++){
            cin>>x;
            s.insert(x);
        }
    }
    cout<<n-s.size();
}
int  main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
    //cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <deque>

using namespace std;

int main(){
  string s;
  cin >> s;
  deque<char> dq;
  for( int i=0; i<s.length(); i++){
  	dq.push_back(s[i]);
  }
  bool f = false;
  int q;
  cin >> q;
  while(q--){
	int t;
    cin >> t;
    if(t==1){
    	f = !f;
    }else{
    	int v;	
      	cin >> v;
      	char ch;
      	cin >> ch;
        if(!f){
        	if(v==1){
            	dq.push_front(ch);
            }else{
            	dq.push_back(ch);
            }
        }else{
        	if(v==2){
            	dq.push_front(ch);
            }else{
            	dq.push_back(ch);
            }
        }       
    }
  }
  
  if(!f){
  	while(!dq.empty()){
    	cout << dq.front();
      	dq.pop_front();
    }
  }else{
  	while(!dq.empty()){
    	cout << dq.back();
      	dq.pop_back();
    }
  }      
  
  return 0;
}


Measured memory_bytes: 896
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

#define rep(i,n)   for (int i = 0; i < (n); i++)
#define rrep(i,n)  for (int i = (n)-1; i >= 0; i--)
#define rep1(i,n)  for (int i = 1; i <= (n); i++)
#define rrep1(i,n) for (int i = (n); i > 0; i--)

ll n;
vector<pair<ll,ll>> v[100001];
vector<ll> d(100001, -1);
int main(void) {
    cin >> n;
    rep(i,n-1) {
        ll a,b,c;
        cin >> a >> b >> c;
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,c));
    }
    vector<ll> q;
    d[1] = 0;
    q.push_back(1);
    while (q.size() != 0) {
        ll idx = q.back();
        q.pop_back();
        while (v[idx].size() != 0) {
            auto p = v[idx].back();
            v[idx].pop_back();
            if (d[p.first] != -1) continue;
            d[p.first] = d[idx] + p.second;
            q.push_back(p.first);
        }
    }
    rep1(i,n) {
        cout << (d[i]%2 == 0 ? "0" : "1") << endl;
    }
    return 0;
}


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

int dp[100000];
int h[100000];

int main()
{
	int N, K;
	cin >> N >> K;
	fill(dp, dp + N, (1 << 31) - 1);
	copy_n(istream_iterator<int>(cin), N, h);
	dp[0] = 0;
	for (int i = 1; i < N; ++i)
	{
		for (int j = 1; j <= K; ++j)
		{
			if (i-j>=0)
				dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
		}
	}
	cout << dp[N-1] << '\n';
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,d;
	cin>>n>>d;
	cout<<(n+(d*2+1)-1)/(d*2+1)<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


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

using ll = long long;
constexpr ll INF = 1000000000;
constexpr ll mod = 1e9 + 7;

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

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
	int x, y;
	cin >> x >> y;

	for (int i = 0; i < x + 1; i++) {
		for (int j = 0; j < x + 1; j++) {
			if (i * 2 + j * 4 == y && i + j == x) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

int main(){
  string s; cin >> s;
  for(char alpha='a'; alpha<='z'; alpha++) {
    if(find(s.begin(),s.end(),alpha)==s.end()) {
   	  cout << alpha << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


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

int main() {
  
  string S,T,U;
  cin >> S >>T;
  int A,B;
  cin >> A >>B;
  cin >> U;


  if(S == U) {
    A--;
  }
  
  else if(T == U) {
    B--;
  }
  
  cout <<A <<" " <<B<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=4e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n;
    cin>>n;
    int res=0,mx=0;
    loop(n,i,0){
        int x;
        cin>>x;
        res+=x;
        max_self(mx,x);
    }
    cout<<res-mx/2<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long pi = 3.14159265358979323846264338327;
int a;
int main() {
	cin >> a;
	if(a<600){
		cout << 8 << endl;
		return 0;
	}else if(a<800){
		cout << 7 << endl;
		return 0;
	}else if(a<1000){
		cout << 6 << endl;
		return 0;
	}else if(a<1200){
		cout << 5 << endl;
		return 0;
	}
	else if(a<1400){
		cout << 4 << endl;
		return 0;
	}else if(a<1600){
		cout << 3 << endl;
		return 0;
	}else if(a<1800){
		cout << 2 << endl;
		return 0;
	}else{
		cout << 1 << endl;
	}
	return 0;
}


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

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

a,b,c=map(int, input().split())

if a%c==0:
    print(b//c-a//c+1)
else:
    print(b//c-a//c)

Measured memory_bytes: 9024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define N 2010
using namespace std;
int nxt[N<<2],to[N<<2],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int in[N];
bool vis[N];
int num[N],n;
void dfs(int u)
{
	vis[u]=true;
	for(int i=1;i<=n;i++)
	if(!vis[i] && __gcd(num[u],num[i])!=1)
	{
		add(u,i);
		in[i]++;
		dfs(i);
	}
}
priority_queue<int>q;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&num[i]);
	sort(num+1,num+n+1);
	for(int i=1;i<=n;i++)
	if(!vis[i])dfs(i);
	for(int i=1;i<=n;i++)
	if(!in[i]) q.push(i);
	while(!q.empty())
	{
		int u=q.top();
		printf("%d ",num[u]);
		q.pop();
		for(int i=head[u];i;i=nxt[i])
		q.push(to[i]);
	}
	
	return 0;
}


Measured memory_bytes: 384
<?php
  class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

$sc = new Scanner();

$sum = $sc->nextInt();
$sum += $sc->nextInt();
$sum += $sc->nextInt();

if ($sum <= 21)
{
	echo "win" . "\n";
}
else
{
	echo "bust" . "\n";	
}



Measured memory_bytes: 4604
#include <iostream>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
int main() {
	/* 入力 */
	int n; cin >> n;
	long long h[100010];
	for (int i = 0; i < n; ++i) cin >> h[i];
	
	/* DPテーブル */
	long long dp[100010];
	for (int i = 0; i < 100010; ++i) dp[i] = INF; // 初期化

	dp[0] = 0;

	for (int i = 1; i < n; ++i) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
N,M = list(map(int, input().split()))
Hs = list(map(int, input().split()))
'''
loads = []
for i in range(M):
    loads.append([list(map(int, input().split()))])
'''
loads = [list(map(int, input().split())) for _ in range(M)]

#print(N)
#print(M)
#print(Hs)
#print(loads)

ans = 0

hoge = [0] * N

for load in loads:
    if(Hs[load[0]-1] < Hs[load[1]-1]):
        hoge[load[0] -1] += 1
    
    elif(Hs[load[0]-1] > Hs[load[1]-1]):
        hoge[load[1]-1] +=1

    else:
        hoge[load[0] -1] += 1
        hoge[load[1]-1] +=1
#print(hoge)
print(hoge.count(0))

Measured memory_bytes: 93324
#include <iostream>

using namespace std;

int main() {
    long long n;
    cin >> n;
    cout << n * (n + 1) / 2
            - (n / 3) * (3 * (n / 3) + 3) / 2
            - (n / 5) * (5 * (n / 5) + 5) / 2
            + (n / 15) * (15 * (n / 15) + 15) / 2 << endl;
}


Measured memory_bytes: 3636
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

  int N;
  cin >> N;
  vector<int> res(N + 1, 0);
  for (int x = 1; x <= 100; x++)
    for (int y = 1; y <= 100; y++)
      for (int z = 1; z <= 100; z++) {
        int fn = x * x + y * y + z * z + x * y + y * z + z * x;
        if (fn > N) break;
        res[fn]++;
      }

  for (int i = 1; i < res.size(); i++)
    cout << res[i] << endl;

  //cout << res << endl;
  return 0;
}

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

int main(){
    int s,w; cin >> s >> w;
    if(w >= s) put("unsafe");
    else put("safe");
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int d[(1 << 26) + 7];
char s[200020];
int main() {
	memset(d, 0x3f, sizeof d);
	scanf("%s", s);
	int n = strlen(s);
	int b = 0;
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		b ^= (1 << (s[i] - 'a'));
		int t = d[b];
		for (int j = 0; j < 26; j++) {
			t = min(t, d[b ^ (1 << j)]);
		}
		d[b] = min(d[b], t + 1);
	}
	printf("%d\n", max(d[b], 1));
	return 0;
}

Measured memory_bytes: 262656
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)




int main() {
  ll N, D;
  cin >> N >> D;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));
  ll ans = 0;

  rep(i, N){
    ll x, y;
    long double dis;
    cin >> x >> y;
    dis = sqrt(pow(x,2) + pow(y,2));
    if(dis <= D){
      ans++; 
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<map>
#include<string>
using namespace std;

typedef pair<string, string> P;

P next_word(string sentence) {
  if (sentence.empty()) return make_pair(string(""), string(""));
  if (sentence[0] == ' ' || sentence[0] == '.') {
    return make_pair("", sentence.substr(1));
  } else {
    P recur = next_word(sentence.substr(1));
    return make_pair(sentence[0] + recur.first, recur.second);
  }
}

bool acceptable(string sentence) {
  P p = next_word(sentence);

  while (! p.first.empty() ) {
    if (p.first == "this" || p.first == "the" || p.first == "that")
      return true;

    p = next_word(p.second);
  }
  return false;
}

char slip(char c) {
  if (c < 'a' || 'z' < c) return c;
  
  string alphabet = "abcdefghijklmnopqrstuvwxyza";
  int index = (int)(c - 'a');
  return alphabet[index + 1];
}

char slip(char c, int n) {
  for (int i = 0; i < n; i++)
    c = slip(c);

  return c;
}

string slip(string code, int n) {
  string val;
  for (int i = 0, len = code.length(); i < len; i++)
    val += slip(code[i], n);

  return val;
}

string decode(string code) {
  for (int i = 1; i < 27; i++) {
    string sentence = slip(code, i);
    if (acceptable(sentence))
      return sentence;
  }

  return "";
}

int main() {
  string code;
  while ( getline(cin, code) )
    cout << decode(code) << endl;
}

Measured memory_bytes: 1192
a, b, c, x, y = map(int, input().split())

ans1 = a * x + b * y
ans2 = 2 * c * max(x, y)
z = min(x, y)
ans3 = 2 * c * z + a * (x - z) + b * (y - z)
print(min(ans1, ans2, ans3))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
pair<long long int, long long int> monsters[200005];
 
long long healths[200005];
void update(long long int point, long long delta, long long int N)
{
	while(point <= N)
	{
		healths[point] += delta;
		point += (point & (-point));
	}
}
 
long long query(long long int point)
{
	long long Sum = 0;
	while(point > 0)
	{
		Sum += healths[point];
		point -= (point & (-point));
	}
	
	return Sum;
}
 
long long posses[200005];
int main()
{
	long long N, D, A;
	scanf("%lld%lld%lld", &N, &D, &A);
	
	long long i;
	for(i = 1; i <= N; i++)
	{
		long long Xi, Hi;
		scanf("%lld%lld", &Xi, &Hi);
		
		monsters[i] = make_pair(Xi, Hi);
	}  
	
	sort(monsters + 1, monsters + N + 1);
	for(i = 1; i <= N; i++)
	{
		update(i, monsters[i].second, N);
		update(i + 1, -monsters[i].second, N);
		
		posses[i] = monsters[i].first;
	}
	
	long long int ans = 0;
	//printf("\n");
	for(i = 1; i <= N; i++)
	{
		long long int health = query(i);
		if(health <= 0)
			continue;
			
		else
		{
			long long endX = posses[i] + 2 * D;
			long long endPos = upper_bound(posses + 1, posses + N + 1, endX) - posses - 1;
			
			long long delta = health / A * A;
			ans += health / A;
			
			//prlong longf("%lld %d\n", health, A);
			
			if(delta < health)
			{
				delta += A;
				ans++;
			}
			
			update(i, -delta, N);
			update(endPos + 1, delta, N);
		}
	}	
	
	printf("%lld", ans);
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define P pair<int, int>
#define F first
#define S second
#define prique priority_queue<P, vector<P>, greater<P>>
using namespace std;

int n,m,x,y[10],a,b,c;
int ta[210][210];
vector<int> mu;
int cnt,ans=inf;

signed main() {
	cin>>n>>m>>x;
	rep(i,x)cin>>y[i];
	rep(i,210){
		rep(j,210)ta[i][j]=inf;
	}
	rep(i,m){
		cin>>a>>b>>c;
		ta[a][b]=c;
		ta[b][a]=c;
	}
	rep(i,x)mu.push_back(y[i]);
	sort(all(mu));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				ta[j][k]=min(ta[j][k],ta[j][i]+ta[i][k]);
			}
		}
	}
	do{
		cnt=0;
		rep(i,mu.size()-1)cnt+=ta[mu[i]][mu[i+1]];
		if(cnt<ans)ans=cnt;
	}while(next_permutation(all(mu)));
	cout<<ans<<endl;
}



Measured memory_bytes: 640
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl;
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc072/tasks/abc072_b
"use strict"
function Main(input) {
  const arrS = input.split('');
  const oddS = arrS.reduce((pre, cur, index) => {
    if ((index + 1) % 2 !== 0) {
      return pre = pre + cur;
    }
    return pre;
  }, '');

  console.log(oddS);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15180
# -*- coding: utf-8 -*-
"""
Created on Tue May  5 00:32:28 2020

@author: Kanaru Sato
"""

n = int(input())
p = list(map(float,input().split()))

dp = [[-1 for i in range(n+1)] for j in range(n)]

for i in range(n,0,-1):
    index = i-1
    for j in range(n-i+2):
        if index == n-1 and j == 0:
            dp[index][j] = 1-p[n-1]
        elif index == n-1 and j == 1:
            dp[index][j] = p[n-1]
        elif j == 0:
            dp[index][j] = dp[index+1][j]*(1-p[index])
        elif 1 <= j and j <= n-i:
            dp[index][j] = dp[index+1][j]*(1-p[index]) + dp[index+1][j-1]*(p[index])
        else:
            dp[index][j] = dp[index+1][j-1]*(p[index])

ans = 0
for j in range(n//2+1,n+1):
    ans += dp[0][j]

print(ans)

Measured memory_bytes: 264584
#include <stdio.h>

int main(void)
{
    int n=0,count=0;
    char string[51]={};
    scanf("%d",&n);
    scanf("%s",string);

    for(int i=0;i<n-2;i++){
        if(string[i]=='A' && string[i+1]=='B' && string[i+2]=='C'){
            count+=1;
            i+=2;
        }
    }

    printf("%d",count);
    return 0;
}


Measured memory_bytes: 1720
import java.util.*;

public class Main {
    public static void main(String args[]) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        Integer[] array = new Integer[n];
        for(int i = 0; i < n; ++i) {
            int num = Integer.parseInt(sc.next());
            array[i] = num;
        }
        
        boolean flag = true;
        int even_counter = 0;
        int counter = 0;
        
        
        for(int item : array) {
            if(item % 2 == 0) {
                ++even_counter;
                if((item % 3 == 0) || (item % 5 ==0)) ++counter;
                else continue;
            }
            else continue;
        }
        
        //System.out.println(even_counter);
        //System.out.println(counter);
        
        if(even_counter == counter) System.out.println("APPROVED");
        else System.out.println("DENIED");
        
    }
}

Measured memory_bytes: 21844
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
const ll mod = 1000000007;
const ll mod9 = 1000000009;

signed main(){
    ll a;
    cin>>a;
    ll ans;
    ans = a+ a*a + a*a*a;
    cout<<ans<<endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[55][55];
    int n, m;
    scanf("%d %d", &n, &m);
    bool judge = 1;
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j)
            scanf(" %c", &a[i][j]);
    }
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j)
            if (a[i][j] == '#'){
                if (!(a[i - 1][j] == '#' || a[i + 1][j] == '#' || a[i][j - 1] == '#' || a[i][j + 1] == '#')){
                    judge = false;
                    break;
                }
            }
    }
    judge ? puts("Yes") : puts("No");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			long n = cin.NextLong();
			long k = cin.NextLong();
			long ans = 1;
            for (int i = 0; i < n; i++)
            {
				if (i != 0) ans *= k - 1;
				else ans *= k;
            }
            Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define For(a,b,c) for(register int a=b;a<=c;++a)
using namespace std;
typedef long long ll;
int l,r;
int main(){
	cin>>l>>r;
	int mi=max(-1000000,r-l+1),ma=min(1000000,r+l-1);
	for(int i=mi;i<=ma;i++){
		printf("%d ",i);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	ll n;
	cin>>n;
	ll ans=0;
	rep(i,n){
		ans+=(n-i+1)*(n-i)/2;
	}
	rep(i,n-1){
		int u,v;
		cin>>u>>v;
		if(u>v)swap(u,v);
		ans-=u*(n-v+1);
	}
	cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3644
#include <string>
#include <iostream>
#include <chrono>
#include <numeric>
#include <map>
#include <algorithm>

using namespace std;
const int nChar = 10;
typedef long long ll;

int main(void)
{
    uint32_t N = 0;
	cin >> N;
	map<string, ll> agrmMap;
 
    for(int idx = 0; idx < N; ++idx) {
        // auto pt1 = chrono::high_resolution_clock::now();
        string str; cin >> str;
		sort(str.begin(), str.end());
		if(agrmMap.find(str) != agrmMap.end()) {
			agrmMap[str]++;
		} else {
			agrmMap[str] = 1;
		}
        // auto pt2 = chrono::high_resolution_clock::now();
        // chrono::duration<double> elapsed = pt2 - pt1;
        // printf("elapsed time ( %d ) = %f [usec]\n", idx, elapsed.count()*1e+6);
    }
	ll nAnagram = 0;
	for(auto& mapPtr : agrmMap) {
		ll count = mapPtr.second;
		nAnagram += count * (count - 1) / 2;
	}
    cout << nAnagram << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", n * (n - 1) / 2 - n / 2);
    for (int i = 1; i < n; ++i) for (int j = i + 1; j <= n; ++j) if (i + j != n + 1 - n % 2) printf("%d %d\n", i, j);
    return 0;
}


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

typedef long long ll;
#define endl "\n"

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

    char c; cin>>c;
    int x=c-'a';
    if (x>=0){
    	cout<<'a';
    }
    else cout<<'A';
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int A, B, C; cin >> A >> B >> C;
    if ((A < C && B > C) || (A > C && B < C)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<string> gift(N);
    for(int i=0;i<N;i++){
        cin >> gift.at(i);
    }
    sort(gift.begin(),gift.end());
    int count=0;
    for(int i=0;i<N-1;i++){
            if(gift.at(i)!=gift.at(i+1)){
                count++;
        }
    }
    cout << count+1 << endl;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll base = 1e6;
int D;
int C[30];
int S[400][30];
int last[400][30];

ll score(vector<int>& t)
{
  ll s = 0LL;
  REP(i,D){
    s += S[i][t[i]];
    REP(j,26) last[i+1][j] = last[i][j];
    last[i+1][t[i]] = i+1;
    REP(j,26){
      s -= C[j] * (i+1-last[i+1][j]);
    } 
  }
  return s;
}

ll score_2(vector<int>& t, ll before, int d, int old, int q)
{
  ll s = before;
  s += S[d][q] - S[d][old];
  FOR(i,d,D){
    if(t[i]==old) break;
    s += C[old] * ((i+1) - last[i+1][old]);
    s -= C[old] * ((i+1) - last[d][old]);
  }
  FOR(i,d,D){
    if(i!=d && t[i]==q) break;
    s += C[q] * ((i+1) - last[i+1][q]);
    s -= C[q] * ((i+1) - (d+1));
  }

  return s;
}

vector<int> init(int sub)
{
  vector<int> t(D);
  REP(i,D) t[i] = (i+sub)%26;
  return t;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  auto T = init(0);
  ll max_score = 0LL;
  REP(sub,26){
    auto tmp = init(sub);
    ll sc = score(tmp);
    if(max_score<sc){
      max_score = sc;
      T = tmp;
    }
  }
  int ti = clock();
  while(clock() - ti < 190 * CLOCKS_PER_SEC / 100){ 
    int d = rand365(mt);
    int q = rand26(mt);
    int old = T[d];
    T[d] = q;
    ll tmp = score_2(T, max_score, d, old, q);
    if(max_score<tmp){
      max_score = tmp;
      FOR(i,d,D){
        if(T[i]==old) break;
        last[i+1][old] = last[d][old];
      }
      FOR(i,d,D){
        if(i!=d && T[i]==q) break;
        last[i+1][q] = (d+1);
      }
    }else{
      T[d] = old;
    }
  }
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3744
using System;


namespace ConsoleApplication46
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int d = int.Parse(input[3]);
            int e = int.Parse(input[4]);
            int f = int.Parse(input[5]);
            //???????????°
            int input2 = int.Parse(Console.ReadLine());
            for (int x = 0; x < input2; x++)
            {
                //?????¨?????¢?????????
                string[] input3 = Console.ReadLine().Split(' ');
                int ue = int.Parse(input3[0]);
                int zen = int.Parse(input3[1]);
                int kari = 0;
                //ue??????
                while (true)
                {
                    if (ue == a)
                    {
                        break;
                    }
                    //cut???a??¨b
                    if (zen == a || zen == f )
                    {
                        kari = a;
                        a = b;
                        b = f;
                        f = e;
                        e = kari;
                    }
                    //cut???
                    if (zen == b || zen == e)
                    {
                        kari = a;
                        a = d;
                        d = f;
                        f = c;
                        c = kari;
                    }
                    //
                    if (zen == c || zen == d)
                    {
                        kari = a;
                        a = b;
                        b = f;
                        f = e;
                        e = kari;
                    }
                }
                //
                while(true)
                {
                    if (zen == b)
                    {
                        break;
                    }
                    if (ue == c || ue == d)
                    {
                        kari = a;
                        a = e;
                        e = f;
                        f = b;
                        b = kari;
                    }
                    else if(ue == b || ue == e)
                    {
                        kari = a;
                        a = c;
                        c = f;
                        f = d;
                        d = kari;
                    }
                    else if (ue == a || ue == f)
                    {
                        kari = b;
                        b = c;
                        c = e;
                        e = d;
                        d = kari;
                    }
                }
                Console.WriteLine(c);
            }
        }
    }
}

Measured memory_bytes: 9208
#include <iostream>
using namespace std;
int main()
{
 int i,n;
 long long int c,s;
 c=s=0;
 cin >> n;
 long long int a[n],b[n];
 for(i=0;i<n;i++)
 {
  cin >> a[i];
  s+=a[i];
  a[i]*=2;
  if(i%2)
  c+=a[i];
 }
 b[0]=s-c;
 for(i=1;i<n;i++)
 b[i]=a[i-1]-b[i-1];
 for(i=0;i<n;i++)
 cout << b[i] << " ";
 return 0;
}

Measured memory_bytes: 2816
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
       int n;cin>>n;
       VEC(int,a,n);
       int res = 0;
       rep(i,n){int b;cin>>b;res+=b;}
       VEC(int,c,n);
       rep(i,n-1){
           if(a[i+1] == a[i]+1)res+=c[a[i]-1];
       }
       cout<<res;
    }
    


Measured memory_bytes: 256
import heapq
N, M = map(int, input().split(" "))
A = list(map(lambda x: -int(x), input().split(" ")))

heapq.heapify(A)

for _ in range(M):
  a = -heapq.heappop(A)
  a = a // 2
  heapq.heappush(A, -a)

print(-sum(A))

Measured memory_bytes: 14180
// https://beta.atcoder.jp/contests/abc066
// status:

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

using i64 = int64_t;
#define SUBMIT
//#define DEBUG

const i64 MOD =  1000000007;
const int MAX_N = 100000;
i64 f[MAX_N + 10];
i64 f_inv[MAX_N + 10];
int a_index[MAX_N + 10];

// 二分累乗法: x^n % mod
i64 power(i64 x, i64 n, i64 mod) {
    i64 res = 1;
    while (n != 0) {
        if (n % 2 == 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 逆元
i64 inverse_element(i64 x, i64 mod) { return power(x, mod - 2, mod); }

template <i64 Size>
void init_factorial(i64 f[Size], i64 f_inv[Size], i64 mod) {
    f[0] = f[1] = 1;
    for (i64 i = 2; i < Size; ++i) f[i] = i * f[i - 1] % mod;

    f_inv[0] = f_inv[1] = 1;
    for (i64 i = 2; i < Size; ++i) f_inv[i] = inverse_element(f[i], mod) % mod;
}

i64 nCk(i64 n, i64 k, i64 mod) {
    if (n < 0 || k < 0 || n < k) return 0;
    return f[n] * f_inv[k] % mod * f_inv[n - k] % mod;
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9
)");
#endif
    init_factorial<MAX_N + 10>(f, f_inv, MOD);
    fill(a_index, a_index + MAX_N + 1, -1);

    i64 n;
    stream >> n;
    int first_index = -1, dupe_index = -1;
    for (int i = 0; i < n + 1; ++i) {
        int a;
        stream >> a;
        if (a_index[a] == -1) {
            a_index[a] = i;
            continue;
        }

        first_index = a_index[a];
        dupe_index = i;
        break;
    }

    i64 s = n + 1;
    for (i64 k = 1; k <= n + 1; ++k) {
        if (k == 1) {
            cout << n << endl;
            continue;
        }
        i64 u = first_index + (n - dupe_index);
        i64 ans = (nCk(s, k, MOD) + MOD - nCk(u, k - 1, MOD)) % MOD;
        cout << ans << endl;
    }

    return 0;
}

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

/*
The patterns to paint 0 to h rows can be represented by 2^h where the options are yes or no, or 0 or 1.
Take an example when h = 2, there are 2^2=4 patterns of painting: 00, 01, 10, 11 or paint no row, paint second row,
paint first row, paint both rows, respectively.
Same for columns. Thus, there are 2^(h+w) patterns of painting.
For all patterns, check the color of the remaining squares. If the number of black squares == k among them,
count that pattern in.
*/

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> grid(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> grid[i][j];

  int count = 0;  // number of patterns that result in exactly k black squares remaining
  rep(pi, 1<<h) rep(pj, 1<<w) {  // for all patterns. pi -> patterns for row. pj -> patterns for column
    int black = 0;
    rep(i, h) rep(j, w) {
      // i-th digit of pi == 1 means that row is all red
      // j-th digit of pj == 1 means that column is all red
      // check color of grid[i][j] that is remaining not red
      if (((pi>>i) & 1) == 0 && ((pj>>j) & 1) == 0 && grid[i][j] == '#') black++;
    }
    if (black == k) count++;  // k black squares are remaining after the operation
  }

  cout << count << endl;
}

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

int main() {
	int a, b, result;
	char op;
	
	while (1) {
		cin >> a >> op >> b;
		if (op == '+') result = a + b;
		else if(op == '-') result = a - b;
		else if(op == '*') result = a * b;
		else if(op == '/') result = a / b;
		else if (op == '?') break;
		cout << result << endl;
	}
}

Measured memory_bytes: 1164
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 29);
ll h, m, n; string s;
const ll MOD= 1000000007;
const ld PI = acos(-1);
ll sum = 0;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    cin >> n; vector<int> a(n),x(n);
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }x[0] = sum;
    for (int i = 1; i < n; i += 2) {
        x[0] -= 2 * a[i];
    }
    req(i, n - 1) {
        x[i] = 2 * a[i - 1] - x[i - 1];
    }
    rep(i, n) cout << x[i] << " ";
    cout << endl;
}

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

using namespace std;
#define ll long long int
#define rep(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
typedef pair< ll, ll > lpair;

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    if(a.ff == b.ff)
        return (a.ss < b.ss);
    return (a.ff < b.ff);
}

vector< ll > prime(1000005,1);
void p()
{
    ll i,j;
    for(i=2;i<=1000000;i++)
    {
        if(prime[i] == 1)
        {
            for(j = 2*i;j<=1000000;j+=i) prime[j] = 0;
        }
    }
}

vector< vector < ll > > adj;
vector< bool > vis;
vector< ll > dis;
ll dfs(ll x)
{
    ll i;
    if(adj[x].size() == 0)
    {
        vis[x] = true;
        return (dis[x] = 0);
    }
    ll temp = 0;
    vis[x] = true;
    for(i = 0;i < adj[x].size();i++)
    {
        if(vis[adj[x][i]] == false)
            temp = max(temp,dfs(adj[x][i]));
        else
            temp = max(temp,dis[adj[x][i]]);
    }

    return (dis[x] = temp +1);
}

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

    ll n,m,x,y,i;
    cin>>n>>m;

    adj.resize(n+1);
    dis.resize(n+1,0);
    vis.resize(n+1,false);

    rep(i,m)
    {
        cin>>x>>y;
        adj[x].pb(y);
    }

    for(i = 1;i<=n;i++)
    {
        if(vis[i] == false)
            dfs(i);
    }

    ll max = 0;
    for(i = 1;i<=n;i++)
    {
        if(dis[i] > max)
            max = dis[i];
    }
    cout<<max<<endl;

    return 0;
}


Measured memory_bytes: 17024